fix: file-show wasn't closing after click on folder inside file-menu
Massimo Melina committed
Sep 10, 2024 at 23:47 UTC
ba8bafac133e1bef66493a409fcd5341dd626da3
1 file changed
+8
frontend/src/show.ts
+8
@@ -22,6 +22,7 @@ enum ZoomMode {
22
export function fileShow(entry: DirEntry, { startPlaying=false } = {}) {
23
let escOnce = false
24
let onClose: any
25
+ let firstUri: string
26
const { close } = newDialog({
27
noFrame: true,
28
className: 'file-show',
@@ -29,6 +30,13 @@ export function fileShow(entry: DirEntry, { startPlaying=false } = {}) {
30
onClose?.()
31
},
32
Content() {
33
+ const { uri } = useSnapState()
34
+ useEffect(() => {
35
+ if (uri === firstUri) return
36
+ firstUri ??= uri // init
37
+ if (firstUri !== uri) // user must have clicked the folder link inside file-menu (which happens only for search results)
38
+ close()
39
+ }, [uri])
40
const [cur, setCur] = useState(entry)
41
const moving = useRef(0)
42
const lastGood = useRef(entry)