@samitouri / QOSami-HFS / commits / 92dc6a32

file-show: repeat

Massimo Melina committed Feb 3, 2024 at 18:48 UTC 92dc6a322216b6a5d6b6ae86720d3ec6320812ae
4 files changed +18 -3
frontend/src/icons.ts
+1
@@ -42,6 +42,7 @@ const SYS_ICONS: Record<string, [string] | [string, string | false]> = { // fals
42 cut: ['✄'],
43 paste: ['📋'],
44 shuffle: ['🔀'],
45 + repeat: ['🔁', 'reload'],
46 }
47
48 document.fonts.ready.then(async ()=> {
frontend/src/show.ts
+13 -1
@@ -25,6 +25,7 @@ export function fileShow(entry: DirEntry) {
25 const lastGood = useRef(entry)
26 const [mode, setMode] = useState(ZoomMode.contain)
27 const [shuffle, setShuffle] = useState<undefined|DirList>()
28 + const [repeat, setRepeat] = useState(false)
29 useEffect(() => {
30 if (shuffle)
31 goTo(shuffle[0])
@@ -46,6 +47,8 @@ export function fileShow(entry: DirEntry) {
47 return toggleFullScreen()
48 if (key === 's')
49 return toggleShuffle()
50 + if (key === 'r')
51 + return toggleRepeat()
52 if (key === ' ') {
53 const sel = state.selected
54 if (sel[cur.uri])
@@ -121,6 +124,7 @@ export function fileShow(entry: DirEntry) {
124 { id: 'zoom', icon: 'zoom', label: t`Switch zoom mode`, onClick: switchZoomMode },
125 { id: 'fullscreen', icon: 'fullscreen', label: t`Full screen`, onClick: toggleFullScreen },
126 { id: 'shuffle', icon: 'shuffle', label: t`Shuffle`, toggled: Boolean(shuffle), onClick: toggleShuffle },
127 + { id: 'repeat', icon: 'repeat', label: t`Repeat`, toggled: repeat, onClick: toggleRepeat },
128 ])),
129 iconBtn('close', close),
130 ),
@@ -174,7 +178,11 @@ export function fileShow(entry: DirEntry) {
178 while (1) {
179 e = e.getSibling(moving.current, shuffle)
180 if (!e) { // reached last
177 - if (dir! > 0) setAutoPlaying(false)
181 + if (dir! > 0) {
182 + if (repeat)
183 + return goTo(shuffle?.[0] || state.list[0])
184 + setAutoPlaying(false)
185 + }
186 goTo(lastGood.current) // revert to last known supported file
187 return restartAnimation(document.body, '.2s blink')
188 }
@@ -206,6 +214,10 @@ export function fileShow(entry: DirEntry) {
214 setShuffle(x => x ? undefined : _.shuffle(state.list))
215 }
216
217 + function toggleRepeat() {
218 + setRepeat(x => !x)
219 + }
220 +
221 function scrollY(dy: number) {
222 containerRef.current?.scrollBy(0, dy * .5 * containerRef.current?.clientHeight)
223 }
src/langs/hfs-lang-en.json
+2 -1
@@ -159,6 +159,7 @@
159 "Select all": "Select all",
160 "go_first": "Go to first item",
161 "go_last": "Go to last item",
162 - "Shuffle": "Shuffle"
162 + "Shuffle": "Shuffle",
163 + "Repeat": "Repeat"
164 }
165 }
src/langs/hfs-lang-it.json
+2 -1
@@ -151,6 +151,7 @@
151 "Select all": "Seleziona tutto",
152 "go_first": "Vai all'inizio",
153 "go_last": "Vai alla fine",
154 - "Shuffle": "Riproduzione casuale"
154 + "Shuffle": "Riproduzione casuale",
155 + "Repeat": "Ripeti a fine lista"
156 }
157 }