mirror of
https://github.com/immich-app/immich.git
synced 2025-12-21 01:11:16 +03:00
* feat(web): lighter timeline buckets * GalleryViewer * weird ssr * Remove generics from AssetInteraction * ensure keys on getAssetInfo, alt-text * empty - trigger ci * re-add alt-text * test fix * update tests * tests * missing import * fix: flappy e2e test * lint * revert settings * unneeded cast * fix after merge * missing import * lint * review * lint * avoid abbreviations * review comment - type safety in test * merge conflicts * lint * lint/abbreviations * fix: left-over migration --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
41 lines
802 B
TypeScript
41 lines
802 B
TypeScript
export class SlideshowHistory {
|
|
private history: { id: string }[] = [];
|
|
private index = 0;
|
|
|
|
constructor(private onChange: (asset: { id: string }) => void) {}
|
|
|
|
reset() {
|
|
this.history = [];
|
|
this.index = 0;
|
|
}
|
|
|
|
queue(asset: { id: string }) {
|
|
this.history.push(asset);
|
|
|
|
// If we were at the end of the slideshow history, move the index to the new end
|
|
if (this.index === this.history.length - 2) {
|
|
this.index++;
|
|
}
|
|
}
|
|
|
|
next(): boolean {
|
|
if (this.index === this.history.length - 1) {
|
|
return false;
|
|
}
|
|
|
|
this.index++;
|
|
this.onChange(this.history[this.index]);
|
|
return true;
|
|
}
|
|
|
|
previous(): boolean {
|
|
if (this.index === 0) {
|
|
return false;
|
|
}
|
|
|
|
this.index--;
|
|
this.onChange(this.history[this.index]);
|
|
return true;
|
|
}
|
|
}
|