Skip to content

Commit db3959b

Browse files
committed
docs(angular): add missing code for loadSaved
1 parent 86f805e commit db3959b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

docs/angular/your-first-app/4-loading-photos.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export class PhotoService {
119119
quality: 100,
120120
});
121121

122+
// Save the picture and add it to photo collection
122123
const savedImageFile = await this.savePicture(capturedPhoto);
123124

124125
this.photos.unshift(savedImageFile);
@@ -166,6 +167,17 @@ export class PhotoService {
166167
// Retrieve cached photo array data
167168
const { value: photoList } = await Preferences.get({ key: this.PHOTO_STORAGE });
168169
this.photos = (photoList ? JSON.parse(photoList) : []) as UserPhoto[];
170+
171+
for (let photo of this.photos) {
172+
// Read each saved photo's data from the Filesystem
173+
const readFile = await Filesystem.readFile({
174+
path: photo.filepath,
175+
directory: Directory.Data,
176+
});
177+
178+
// Web platform only: Load the photo as base64 data
179+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
180+
}
169181
}
170182
}
171183

versioned_docs/version-v7/angular/your-first-app/4-loading-photos.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export class PhotoService {
119119
quality: 100,
120120
});
121121

122+
// Save the picture and add it to photo collection
122123
const savedImageFile = await this.savePicture(capturedPhoto);
123124

124125
this.photos.unshift(savedImageFile);
@@ -166,6 +167,17 @@ export class PhotoService {
166167
// Retrieve cached photo array data
167168
const { value: photoList } = await Preferences.get({ key: this.PHOTO_STORAGE });
168169
this.photos = (photoList ? JSON.parse(photoList) : []) as UserPhoto[];
170+
171+
for (let photo of this.photos) {
172+
// Read each saved photo's data from the Filesystem
173+
const readFile = await Filesystem.readFile({
174+
path: photo.filepath,
175+
directory: Directory.Data,
176+
});
177+
178+
// Web platform only: Load the photo as base64 data
179+
photo.webviewPath = `data:image/jpeg;base64,${readFile.data}`;
180+
}
169181
}
170182
}
171183

0 commit comments

Comments
 (0)