fix(SearchLocal): add confirmation dialog for rebuilding search index
This commit is contained in:
parent
251e9a9495
commit
ca8f20c598
|
|
@ -174,6 +174,7 @@ export default function SearchLocal({ config, setConfig, onClose, onOpenFolder }
|
||||||
const [hasSearched, setHasSearched] = useState(() => _store.hasSearched);
|
const [hasSearched, setHasSearched] = useState(() => _store.hasSearched);
|
||||||
const [mountEntry, setMountEntry] = useState<SearchResult | null>(null);
|
const [mountEntry, setMountEntry] = useState<SearchResult | null>(null);
|
||||||
const [actionEntry, setActionEntry] = useState<SearchResult | null>(null);
|
const [actionEntry, setActionEntry] = useState<SearchResult | null>(null);
|
||||||
|
const [showScanConfirm, setShowScanConfirm] = useState(false);
|
||||||
const [searchError, setSearchError] = useState<string | null>(null);
|
const [searchError, setSearchError] = useState<string | null>(null);
|
||||||
// The locate-database load progress is rendered by the SearchPane (above
|
// The locate-database load progress is rendered by the SearchPane (above
|
||||||
// this panel). The pane pre-fetches the database on mount, so by the time
|
// this panel). The pane pre-fetches the database on mount, so by the time
|
||||||
|
|
@ -352,7 +353,7 @@ export default function SearchLocal({ config, setConfig, onClose, onOpenFolder }
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<button
|
<button
|
||||||
onClick={handleScan}
|
onClick={() => setShowScanConfirm(true)}
|
||||||
disabled={busy}
|
disabled={busy}
|
||||||
className="p-1.5 rounded-lg hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600 disabled:opacity-40 transition-colors"
|
className="p-1.5 rounded-lg hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600 disabled:opacity-40 transition-colors"
|
||||||
title="Scan /sd and rebuild database"
|
title="Scan /sd and rebuild database"
|
||||||
|
|
@ -517,6 +518,32 @@ export default function SearchLocal({ config, setConfig, onClose, onOpenFolder }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Scan confirm dialog */}
|
||||||
|
<Dialog open={showScanConfirm} onOpenChange={setShowScanConfirm}>
|
||||||
|
<DialogContent className="max-w-sm">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>Rebuild Search Index</DialogTitle>
|
||||||
|
<DialogDescription>
|
||||||
|
This will scan all files on <code>/sd</code> and rebuild the local search database. It may take a minute on large collections.
|
||||||
|
</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<div className="flex gap-2 justify-end pt-1">
|
||||||
|
<button
|
||||||
|
onClick={() => setShowScanConfirm(false)}
|
||||||
|
className="px-4 py-2 rounded-xl text-sm text-neutral-600 hover:bg-neutral-100 transition-colors"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => { setShowScanConfirm(false); handleScan(); }}
|
||||||
|
className="px-4 py-2 rounded-xl text-sm font-medium bg-blue-600 text-white hover:bg-blue-700 transition-colors"
|
||||||
|
>
|
||||||
|
Scan
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
|
||||||
{/* Actions dialog */}
|
{/* Actions dialog */}
|
||||||
<Dialog open={actionEntry !== null} onOpenChange={open => !open && setActionEntry(null)}>
|
<Dialog open={actionEntry !== null} onOpenChange={open => !open && setActionEntry(null)}>
|
||||||
<DialogContent className="max-w-sm">
|
<DialogContent className="max-w-sm">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user