Skip to content

docs(your-first-app): switch to Date.now() #2915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/angular/your-first-app/3-saving-photos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion docs/angular/your-first-app/5-adding-mobile.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion docs/react/your-first-app/2-taking-photos.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const [photos, setPhotos] = useState<UserPhoto[]>([]);
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,
Expand Down
2 changes: 1 addition & 1 deletion docs/react/your-first-app/3-saving-photos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion docs/vue/your-first-app/2-taking-photos.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const photos = ref<UserPhoto[]>([]);
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,
Expand Down
2 changes: 1 addition & 1 deletion docs/vue/your-first-app/3-saving-photos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const [photos, setPhotos] = useState<UserPhoto[]>([]);
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const photos = ref<UserPhoto[]>([]);
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down