From f62dcac014bda4ab6e5de7c5679ed0af5381516a Mon Sep 17 00:00:00 2001 From: Gaspard Damoiseau-Malraux <67809939+Biskweet@users.noreply.github.com> Date: Thu, 13 Apr 2023 22:08:42 -0400 Subject: [PATCH 1/4] Improving docs I replaced `new Date().getTime()` with the static method `Date.now()` because the previous was over-engineering and had worse performance. --- docs/react/your-first-app/3-saving-photos.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/react/your-first-app/3-saving-photos.md b/docs/react/your-first-app/3-saving-photos.md index cc6224d68a1..eae9a61df7b 100644 --- a/docs/react/your-first-app/3-saving-photos.md +++ b/docs/react/your-first-app/3-saving-photos.md @@ -71,7 +71,7 @@ const takePhoto = async () => { quality: 100, }); - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFileImage = await savePicture(photo, fileName); const newPhotos = [savedFileImage, ...photos]; setPhotos(newPhotos); From 6cb20eef2f83640177e59dec3fa30e470b63be52 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Mon, 26 Jun 2023 11:04:59 -0700 Subject: [PATCH 2/4] docs(your-first-app): switch to Date.now() --- docs/angular/your-first-app/3-saving-photos.md | 2 +- docs/angular/your-first-app/5-adding-mobile.md | 2 +- docs/react/your-first-app/2-taking-photos.md | 2 +- docs/vue/your-first-app/2-taking-photos.md | 2 +- docs/vue/your-first-app/3-saving-photos.md | 2 +- .../version-v6/angular/your-first-app/3-saving-photos.md | 2 +- .../version-v6/angular/your-first-app/5-adding-mobile.md | 2 +- .../version-v6/react/your-first-app/2-taking-photos.md | 2 +- .../version-v6/react/your-first-app/3-saving-photos.md | 2 +- versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md | 2 +- versioned_docs/version-v6/vue/your-first-app/3-saving-photos.md | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/angular/your-first-app/3-saving-photos.md b/docs/angular/your-first-app/3-saving-photos.md index 27109d61432..c1e013a8bec 100644 --- a/docs/angular/your-first-app/3-saving-photos.md +++ b/docs/angular/your-first-app/3-saving-photos.md @@ -39,7 +39,7 @@ private async savePicture(photo: Photo) { const base64Data = await this.readAsBase64(photo); // Write the file to the data directory - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFile = await Filesystem.writeFile({ path: fileName, data: base64Data, diff --git a/docs/angular/your-first-app/5-adding-mobile.md b/docs/angular/your-first-app/5-adding-mobile.md index 3a3ebd92f23..ce7f60e75c5 100644 --- a/docs/angular/your-first-app/5-adding-mobile.md +++ b/docs/angular/your-first-app/5-adding-mobile.md @@ -62,7 +62,7 @@ private async savePicture(photo: Photo) { const base64Data = await this.readAsBase64(photo); // Write the file to the data directory - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFile = await Filesystem.writeFile({ path: fileName, data: base64Data, diff --git a/docs/react/your-first-app/2-taking-photos.md b/docs/react/your-first-app/2-taking-photos.md index 513d1a19d1f..9693e233c53 100644 --- a/docs/react/your-first-app/2-taking-photos.md +++ b/docs/react/your-first-app/2-taking-photos.md @@ -98,7 +98,7 @@ const [photos, setPhotos] = useState([]); When the camera is done taking a picture, the resulting Photo returned from Capacitor will be stored in the `photo` variable. We want to create a new photo object and add it to the photos state array. We make sure we don't accidently mutate the current photos array by making a new array, and then call `setPhotos` to store the array into state. Update the `takePhoto` method and add this code after the getPhoto call: ```tsx -const fileName = new Date().getTime() + '.jpeg'; +const fileName = Date.now() + '.jpeg'; const newPhotos = [ { filepath: fileName, diff --git a/docs/vue/your-first-app/2-taking-photos.md b/docs/vue/your-first-app/2-taking-photos.md index c95399f7024..9e50677a499 100644 --- a/docs/vue/your-first-app/2-taking-photos.md +++ b/docs/vue/your-first-app/2-taking-photos.md @@ -104,7 +104,7 @@ const photos = ref([]); When the camera is done taking a picture, the resulting `Photo` returned from Capacitor will be added to the `photos` array. Update the `takePhoto` function, adding this code after the `Camera.getPhoto` line: ```tsx -const fileName = new Date().getTime() + '.jpeg'; +const fileName = Date.now() + '.jpeg'; const savedFileImage = { filepath: fileName, webviewPath: photo.webPath, diff --git a/docs/vue/your-first-app/3-saving-photos.md b/docs/vue/your-first-app/3-saving-photos.md index 429ae929645..04f5085738f 100644 --- a/docs/vue/your-first-app/3-saving-photos.md +++ b/docs/vue/your-first-app/3-saving-photos.md @@ -60,7 +60,7 @@ const takePhoto = async () => { quality: 100, }); - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFileImage = await savePicture(photo, fileName); photos.value = [savedFileImage, ...photos.value]; diff --git a/versioned_docs/version-v6/angular/your-first-app/3-saving-photos.md b/versioned_docs/version-v6/angular/your-first-app/3-saving-photos.md index 27109d61432..c1e013a8bec 100644 --- a/versioned_docs/version-v6/angular/your-first-app/3-saving-photos.md +++ b/versioned_docs/version-v6/angular/your-first-app/3-saving-photos.md @@ -39,7 +39,7 @@ private async savePicture(photo: Photo) { const base64Data = await this.readAsBase64(photo); // Write the file to the data directory - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFile = await Filesystem.writeFile({ path: fileName, data: base64Data, diff --git a/versioned_docs/version-v6/angular/your-first-app/5-adding-mobile.md b/versioned_docs/version-v6/angular/your-first-app/5-adding-mobile.md index 3c6190e3799..28988755a4c 100644 --- a/versioned_docs/version-v6/angular/your-first-app/5-adding-mobile.md +++ b/versioned_docs/version-v6/angular/your-first-app/5-adding-mobile.md @@ -62,7 +62,7 @@ private async savePicture(photo: Photo) { const base64Data = await this.readAsBase64(photo); // Write the file to the data directory - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFile = await Filesystem.writeFile({ path: fileName, data: base64Data, diff --git a/versioned_docs/version-v6/react/your-first-app/2-taking-photos.md b/versioned_docs/version-v6/react/your-first-app/2-taking-photos.md index 90c527521bd..1c460796688 100644 --- a/versioned_docs/version-v6/react/your-first-app/2-taking-photos.md +++ b/versioned_docs/version-v6/react/your-first-app/2-taking-photos.md @@ -98,7 +98,7 @@ const [photos, setPhotos] = useState([]); When the camera is done taking a picture, the resulting Photo returned from Capacitor will be stored in the `photo` variable. We want to create a new photo object and add it to the photos state array. We make sure we don't accidently mutate the current photos array by making a new array, and then call `setPhotos` to store the array into state. Update the `takePhoto` method and add this code after the getPhoto call: ```tsx -const fileName = new Date().getTime() + '.jpeg'; +const fileName = Date.now() + '.jpeg'; const newPhotos = [ { filepath: fileName, diff --git a/versioned_docs/version-v6/react/your-first-app/3-saving-photos.md b/versioned_docs/version-v6/react/your-first-app/3-saving-photos.md index cc6224d68a1..eae9a61df7b 100644 --- a/versioned_docs/version-v6/react/your-first-app/3-saving-photos.md +++ b/versioned_docs/version-v6/react/your-first-app/3-saving-photos.md @@ -71,7 +71,7 @@ const takePhoto = async () => { quality: 100, }); - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFileImage = await savePicture(photo, fileName); const newPhotos = [savedFileImage, ...photos]; setPhotos(newPhotos); diff --git a/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md b/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md index 8fe97523339..74513752c2d 100644 --- a/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md +++ b/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md @@ -106,7 +106,7 @@ const photos = ref([]); When the camera is done taking a picture, the resulting `Photo` returned from Capacitor will be added to the `photos` array. Update the `takePhoto` method, adding this code after the `Camera.getPhoto` line: ```tsx -const fileName = new Date().getTime() + '.jpeg'; +const fileName = Date.now() + '.jpeg'; const savedFileImage = { filepath: fileName, webviewPath: photo.webPath, diff --git a/versioned_docs/version-v6/vue/your-first-app/3-saving-photos.md b/versioned_docs/version-v6/vue/your-first-app/3-saving-photos.md index 59b165ca9ab..8d06a3ea673 100644 --- a/versioned_docs/version-v6/vue/your-first-app/3-saving-photos.md +++ b/versioned_docs/version-v6/vue/your-first-app/3-saving-photos.md @@ -62,7 +62,7 @@ const takePhoto = async () => { quality: 100, }); - const fileName = new Date().getTime() + '.jpeg'; + const fileName = Date.now() + '.jpeg'; const savedFileImage = await savePicture(photo, fileName); photos.value = [savedFileImage, ...photos.value]; From fe7cd9c427d04a98818f30c1d73061134fd09cfa Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Mon, 26 Jun 2023 13:13:18 -0700 Subject: [PATCH 3/4] docs(your-first-app): new line --- versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md | 1 + 1 file changed, 1 insertion(+) diff --git a/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md b/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md index 74513752c2d..5309359be83 100644 --- a/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md +++ b/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md @@ -107,6 +107,7 @@ When the camera is done taking a picture, the resulting `Photo` returned from Ca ```tsx const fileName = Date.now() + '.jpeg'; + const savedFileImage = { filepath: fileName, webviewPath: photo.webPath, From 36340a814e11cf3a27002a7cef9b8c557ce9f61b Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Mon, 26 Jun 2023 13:14:57 -0700 Subject: [PATCH 4/4] docs(many): remove new line --- versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md | 1 - 1 file changed, 1 deletion(-) diff --git a/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md b/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md index 5309359be83..74513752c2d 100644 --- a/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md +++ b/versioned_docs/version-v6/vue/your-first-app/2-taking-photos.md @@ -107,7 +107,6 @@ When the camera is done taking a picture, the resulting `Photo` returned from Ca ```tsx const fileName = Date.now() + '.jpeg'; - const savedFileImage = { filepath: fileName, webviewPath: photo.webPath,