Skip to content

[PB-7047]: feat/show the thumbnails of the photos as they scroll into view - #2292

Open
xabg2 wants to merge 3 commits into
feat/PB-7047-photos-month-gridfrom
feat/PB-7047-photos-thumbnails
Open

xabg2 wants to merge 3 commits into
feat/PB-7047-photos-month-gridfrom
feat/PB-7047-photos-thumbnails

Conversation

@xabg2

@xabg2 xabg2 commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Description

The photos in the Photos gallery now show their thumbnail instead of the file type icon. A thumbnail starts downloading just before its photo scrolls into view, and the download is cancelled if the user scrolls past it before it finishes. While it loads the tile shows a placeholder. Thumbnails already downloaded are taken from the local previews cache that Drive uses, so they are not downloaded again. If a photo has no thumbnail or it cannot be downloaded, the file type icon is shown. When a photo has several thumbnails (for example after being edited on the phone), the latest one is used.

Drive's thumbnail download can now be cancelled. Drive keeps its current behaviour.

Related Issues

Jira: PB-7047 (parent PB-6876)

Related Pull Requests

Checklist

  • Changes have been tested locally.
  • Unit tests have been written or updated as necessary.
  • The code adheres to the repository's coding standards.
  • Relevant documentation has been added or updated.
  • No new warnings or errors have been introduced.
  • SonarCloud issues have been reviewed and addressed.
  • QA Passed

Testing Process

  • Unit tests cover a thumbnail being downloaded and shown, a cached thumbnail shown without downloading it again, the file type icon when the download fails, the latest thumbnail being picked when a photo has several, and cancelling Drive's thumbnail download.

Additional Notes

The page is still not linked from the sidebar.

@xabg2 xabg2 added the enhancement New feature or request label Nov 5, 2026
@xabg2 xabg2 self-assigned this Nov 5, 2026
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 55948fa7-4352-4563-82f7-74bdf0cf7e10

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Deploying drive-web with  Cloudflare Pages  Cloudflare Pages

Latest commit: f5db2fe
Status: ✅  Deploy successful!
Preview URL: https://0e3bc913.drive-web.pages.dev
Branch Preview URL: https://feat-pb-7047-photos-thumbnai.drive-web.pages.dev

View logs

@xabg2
xabg2 marked this pull request as ready for review November 6, 2026 12:57

async getThumbnail(photo: Photo, thumbnail: PhotoThumbnail, abortController: AbortController): Promise<Blob> {
const cachedPreview = await getDatabaseFilePreviewData({ fileId: photo.id });
if (cachedPreview?.preview) return cachedPreview.preview;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getThumbnail returns the cached blob keyed only by fileId, with no check against the thumbnail id or updatedAt. Once cached, a stale pre-edit thumbnail is served forever, contradicting the PR's own "latest one is used" behavior.

Maybe you can key the cache check on thumbnail id (or compare updatedAt) before returning the cached blob.

if (cachedPreview?.preview) return cachedPreview.preview;

const thumbnailBlob = await downloadThumbnail(thumbnail, false, abortController);
void updateDatabaseFilePreviewData({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateDatabaseFilePreviewData is fire-and-forget with no .catch. A failed IndexedDB write becomes an unhandled promise rejection instead of going through errorService, and silently disables caching for that photo.

adding .catch(errorService.reportError) should be enough, right? 🤔

return () => abortController.abort();
}, [photo, shouldLoad]);

useEffect(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thumbnail state is split across two useState + two effects (blob, then derived URL), adding an extra render per load. But PublicSharedItemList.tsx's equivalent creates the object URL directly on download resolution 🤔

const thumbnail = usePhotoThumbnail(photo, isNearViewport);
const FileIcon = iconService.getItemIcon(false, photo.type);

const content = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iconService.getItemIcon and all three content branches are computed on every render, even though only one is shown. Wasted work that scales with grid size, it could be avoidable with a switch/ternary on thumbnail.status, right?

@xabg2
xabg2 requested a review from larryrider November 6, 2026 16:50
…into feat/PB-7047-photos-thumbnails

# Conflicts:
#	src/views/Photos/services/photoFolders.service.ts
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants