Skip to content

feat: keyboard navigation to timeline - #17798

Merged
alextran1502 merged 76 commits into
mainfrom
keynav_timeline
May 28, 2025
Merged

alextran1502 merged 76 commits into
mainfrom
keynav_timeline

Conversation

@midzelis

@midzelis midzelis commented Apr 23, 2025 •

Copy link
Copy Markdown
Collaborator

Description

Note: this PR is stacked with PR #17796

This PR adds the ability to navigate timeline using keyboard shortcuts. Using d/D for next/previous day, m/M for month, y/Y for year. And 'G' to open a 'goto' dialog, to go to any date.

@midzelis midzelis changed the title feat: improve focus feat: keyboard navigation to timeline Apr 23, 2025
@github-actions github-actions Bot added documentation Improvements or additions to documentation 📱mobile 🗄️server labels Apr 23, 2025
@midzelis midzelis removed documentation Improvements or additions to documentation 🗄️server 📱mobile labels Apr 23, 2025
@github-actions github-actions Bot added documentation Improvements or additions to documentation 📱mobile 🗄️server labels Apr 23, 2025
@midzelis midzelis removed documentation Improvements or additions to documentation 🗄️server labels Apr 23, 2025
@bo0tzz bo0tzz removed the preview label May 23, 2025
Comment thread web/src/lib/components/photos-page/actions/focus-actions.ts Outdated
Comment thread web/src/lib/utils/timeline-util.ts Outdated

@danieldietzler danieldietzler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Iterators definitely made this a lot more elegant.

Comment thread web/src/lib/components/photos-page/actions/focus-actions.ts Outdated
Comment thread web/src/lib/stores/assets-store.svelte.ts Outdated
Comment thread web/src/lib/stores/assets-store.svelte.ts Outdated
Comment thread web/src/lib/stores/assets-store.svelte.ts
Comment on lines +639 to +641
findAssetById(assetDescriptor: AssetDescriptor) {
return this.assetsIterator().find((asset) => asset.id === assetDescriptor.id);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't really know how easy that'd be with your current data model, but just a thought: We could potentially get data information for that asset id through the API. Would we be able to more efficiently grab the correct bucket (or even a small set of buckets, I don't really care) to then only linearly search within that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Any actual api call will far outweigh the gains in efficiency. That said, sometimes we do know the date, and we can create an optimized one that uses binary search in those cases. But that would be a future PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe I'm misunderstanding then. This won't possibly iterate over 1M assets?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This specific method is defined on AssetBucket, so its limited to a single bucket. The bucket was already loaded. This is used when navigating to a specific asset given only an asset id (from the URL). The entire asset is retrieved (getAssetInfo) - then the bucket for that asset is found (searching for yearMonth), and then, within that bucket, it searches for the asset. However, there are a few places where we already have asset instead of just id, and this search can be eliminated. I'll update with more efficient versions

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

On second thought, we don't actually have the real asset. When the keynav keystroke is pressed, it looks up the current asset using a data-asset attribute. A LRU cache could help, but honestly, the lookups are pretty fast. We could add a LRU cache later, but it would make things a bit more complex. That should be done if profiling determines its necessary, and in a diff PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah I don't really think we need to employ caching here. The timeline is already very fast.

Comment thread web/src/lib/stores/assets-store.svelte.ts Outdated
Comment thread web/src/lib/stores/assets-store.svelte.ts
Comment thread web/src/lib/stores/assets-store.svelte.ts
Comment thread web/src/lib/utils/timeline-util.ts
@alextran1502
alextran1502 merged commit f029910 into main May 28, 2025
@alextran1502
alextran1502 deleted the keynav_timeline branch May 28, 2025 13:55
@github-actions github-actions Bot removed the preview label May 28, 2025
savely-krasovsky pushed a commit to savely-krasovsky/immich that referenced this pull request Jun 8, 2025
* feat: improve focus

* feat: keyboard nav

* feat: improve focus

* typo

* test

* fix test

* lint

* bad merge

* lint

* inadvertent

* lint

* fix: flappy e2e test

* bad merge and fix tests

* use modulus in loop

* tests

* react to modal dialog refactor

* regression due to deferLayout

* Review comments

* Re-use change-date instead of new component

* bad merge

* Review comments

* rework moveFocus

* lint

* Fix outline

* use Date

* Finish up removing/reducing date parsing

* lint

* title

* strings

* Rework dates, rework earlier/later algorithm

* bad merge

* fix tests

* Fix race in scroll comp

* consolidate scroll methods

* Review comments

* console.log

* Edge cases in scroll compensation

* edge case, optimizations

* review comments

* lint

* lint

* More edge cases

* lint

---------

Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants