Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
mnvr committed Feb 17, 2025
1 parent 9d76d93 commit 36e7dae
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions web/packages/gallery/components/viewer/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ type ItemData = SlideData & {
livePhotoVideoURL?: string;
isContentLoading?: boolean;
isContentZoomable?: boolean;
isFinal?: boolean;
};

/**
Expand Down Expand Up @@ -98,16 +97,13 @@ export class FileViewerDataSource {
*/
itemDataForFile(file: EnteFile, needsRefresh: () => void) {
let itemData = this.itemDataByFileID.get(file.id);
if (itemData) {
if (!itemData.isFinal) {
// We assume that there is only one file viewer that is using us
// at a given point of time. This assumption is currently valid.
this.needsRefreshByFileID.set(file.id, needsRefresh);
}
} else {
// We assume that there is only one file viewer that is using us
// at a given point of time. This assumption is currently valid.
this.needsRefreshByFileID.set(file.id, needsRefresh);

if (!itemData) {
itemData = {};
this.itemDataByFileID.set(file.id, itemData);
this.needsRefreshByFileID.set(file.id, needsRefresh);
void this.enqueueUpdates(file);
}

Expand All @@ -134,7 +130,8 @@ export class FileViewerDataSource {
const sourceURLs =
await downloadManager.renderableSourceURLs(file);
// TODO(PS):
update(await withDimensions(sourceURLs.url as string));
const itemData = await withDimensions(sourceURLs.url as string);
update(itemData);
break;
}

Expand Down

0 comments on commit 36e7dae

Please sign in to comment.