Skip to content

Fix timeline mode wrong indexing.#3364

Merged
ildyria merged 3 commits intomasterfrom
fix-indexing
May 24, 2025
Merged

Fix timeline mode wrong indexing.#3364
ildyria merged 3 commits intomasterfrom
fix-indexing

Conversation

@ildyria
Copy link
Copy Markdown
Member

@ildyria ildyria commented May 20, 2025

Fixes #3313

Executive summary

So what is going on here?

The problem is that the ordering of the photos from the API is not necessarily the same as the ordering of the photos in the timeline. The timeline is constructed from the photos taken_at data and if not provided, created_at data.
This is split into different chunks based on the granularity. If the ordering is done by created_at, and the order of the photos match, we do not have problems. But if one of the photos has a different taken_at date, that does not match the order, then all the following photos are "moved" to different place which does not match the original index ordering.

When we click on a photo, the index returned refers to the original ordering of the photos. As a result, if the timeline is enabled, we first do the split and then merge the photos so that the ordering is updated to reflect the timeline.

Note that this is not something that can be fixed in the backend as we would need to assume that all the dates are set properly. Furthermore, this would make the functionality unavailable if sorting by title is done. By doing it in the front-end, we are able to display the photos by blocks of time, and within the block, the ordering is done as expected.

Copilot summary

This pull request introduces significant changes to enhance the handling of photo timelines and improve the modularity of the codebase. The key updates include adding support for photo timelines in various components, refactoring timeline-related logic for better maintainability, and introducing new utility functions in the splitter module. Below is a categorized summary of the most important changes:

Timeline Support and Refactoring

  • Added photosTimeline as a new prop to components like AlbumPanel, PhotoThumbPanel, and ResultPanel to support displaying photos grouped by timeline. This includes updating computed properties and templates to use the new timeline data. [1] [2] [3]
  • Refactored timeline splitting logic to ensure proper ordering of photos when timelines are enabled. Introduced a merge function to reconstruct photos from timeline chunks and a verifyOrder function for debugging timeline data integrity. [1] [2]

Component Updates

  • Updated PhotoThumbPanelList to replace idx with groupIdx for better clarity when working with grouped timeline data. Adjusted related logic for event handling and lazy loading. [1] [2]
  • Added validation and reactivity for timeline data in PhotoThumbPanel and AlbumThumbPanel, including onMounted and watch hooks to handle changes in album or timeline state. [1] [2]

Utility Enhancements

  • Enhanced the splitter module with new functions: merge for combining split data back into a single array and verifyOrder for ensuring timeline data matches the original photo order. These utilities improve the robustness of timeline handling.

Service and API Adjustments

  • Updated the AlbumService.get method to handle different response structures, accommodating changes in how album data is retrieved.

Codebase Integration

  • Integrated timeline-related changes into the useAlbumRefresher composable, ensuring that photos and timelines are properly synchronized and merged when timelines are enabled. [1] [2]

These changes collectively improve the user experience by introducing timeline-based photo organization while enhancing the maintainability and modularity of the codebase.

@ildyria ildyria requested a review from a team as a code owner May 20, 2025 07:45
@ildyria ildyria added the Review: easy Easy review expected: probably just need a quick to go through. label May 20, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.99%. Comparing base (b5b5d9c) to head (8a5e9f8).
Report is 2 commits behind head on master.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ildyria ildyria changed the title Add checks in debug mode for timeline ordering. Fix timeline mode wrong indexing. May 20, 2025
@ildyria ildyria added High Priority High priority issues alpha-ready Branch is available in alpha labels May 20, 2025
@ildyria ildyria merged commit 314f48e into master May 24, 2025
35 checks passed
@ildyria ildyria deleted the fix-indexing branch May 24, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

alpha-ready Branch is available in alpha High Priority High priority issues Review: easy Easy review expected: probably just need a quick to go through.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect photo index on mouse click after uploading photos over a day without DB optimization.

2 participants