mirror of
https://github.com/immich-app/immich.git
synced 2025-01-10 13:56:47 +01:00
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
|
import { persisted } from 'svelte-local-storage-store';
|
||
|
import { writable } from 'svelte/store';
|
||
|
|
||
|
export enum SlideshowState {
|
||
|
PlaySlideshow = 'play-slideshow',
|
||
|
StopSlideshow = 'stop-slideshow',
|
||
|
None = 'none',
|
||
|
}
|
||
|
|
||
|
function createSlideshowStore() {
|
||
|
const restartState = writable<boolean>(false);
|
||
|
const stopState = writable<boolean>(false);
|
||
|
|
||
|
const slideshowShuffle = persisted<boolean>('slideshow-shuffle', true);
|
||
|
const slideshowState = writable<SlideshowState>(SlideshowState.None);
|
||
|
|
||
|
return {
|
||
|
restartProgress: {
|
||
|
subscribe: restartState.subscribe,
|
||
|
set: (value: boolean) => {
|
||
|
// Trigger an action whenever the restartProgress is set to true. Automatically
|
||
|
// reset the restart state after that
|
||
|
if (value) {
|
||
|
restartState.set(true);
|
||
|
restartState.set(false);
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
stopProgress: {
|
||
|
subscribe: stopState.subscribe,
|
||
|
set: (value: boolean) => {
|
||
|
// Trigger an action whenever the stopProgress is set to true. Automatically
|
||
|
// reset the stop state after that
|
||
|
if (value) {
|
||
|
stopState.set(true);
|
||
|
stopState.set(false);
|
||
|
}
|
||
|
},
|
||
|
},
|
||
|
slideshowShuffle,
|
||
|
slideshowState,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
export const slideshowStore = createSlideshowStore();
|