Make library hide/reveal instant instead of rewriting the whole catalog.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -109,7 +109,6 @@
|
||||
type="button"
|
||||
class="rounded-full bg-zinc-950/80 p-1.5 text-amber-100 hover:bg-zinc-900 disabled:opacity-50"
|
||||
:title="still.hideInput ? 'Show thumbnail' : 'Hide thumbnail'"
|
||||
:disabled="hidingId === still.id"
|
||||
@click.stop="toggleHidden(still)"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="h-4 w-4">
|
||||
@@ -237,6 +236,7 @@ const activeFolderId = ref(props.folderId)
|
||||
const tab = ref<'input' | 'output'>('input')
|
||||
const revealAll = ref(false)
|
||||
const revealedIds = ref<string[]>([])
|
||||
const forceHiddenIds = ref<string[]>([])
|
||||
const picking = ref(false)
|
||||
const keepingId = ref('')
|
||||
const hidingId = ref('')
|
||||
@@ -285,28 +285,42 @@ function isRevealed(id: string) {
|
||||
}
|
||||
|
||||
function thumbBlurred(still: PickerStill) {
|
||||
if (forceHiddenIds.value.includes(still.id)) return true
|
||||
return stillHidden(still) && !isRevealed(still.id)
|
||||
}
|
||||
|
||||
async function toggleHidden(still: PickerStill) {
|
||||
if (hidingId.value) return
|
||||
if (hidingId.value === still.id) return
|
||||
const nextHide = still.hideInput !== true
|
||||
const previous = still.hideInput === true
|
||||
still.hideInput = nextHide
|
||||
if (nextHide) {
|
||||
revealedIds.value = revealedIds.value.filter(id => id !== still.id)
|
||||
if (revealAll.value && !forceHiddenIds.value.includes(still.id)) {
|
||||
forceHiddenIds.value = [...forceHiddenIds.value, still.id]
|
||||
}
|
||||
} else {
|
||||
forceHiddenIds.value = forceHiddenIds.value.filter(id => id !== still.id)
|
||||
}
|
||||
hidingId.value = still.id
|
||||
try {
|
||||
emit('updated', await $fetch(`/api/library/stills/${still.id}`, {
|
||||
method: 'PATCH',
|
||||
body: { hideInput: still.hideInput !== true }
|
||||
body: { hideInput: nextHide }
|
||||
}))
|
||||
revealedIds.value = revealedIds.value.filter(id => id !== still.id)
|
||||
} catch (error: any) {
|
||||
still.hideInput = previous
|
||||
forceHiddenIds.value = forceHiddenIds.value.filter(id => id !== still.id)
|
||||
emit('error', error?.data?.statusMessage || 'Could not update thumbnail')
|
||||
} finally {
|
||||
hidingId.value = ''
|
||||
if (hidingId.value === still.id) hidingId.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
function toggleRevealAll() {
|
||||
revealAll.value = !revealAll.value
|
||||
revealedIds.value = []
|
||||
forceHiddenIds.value = []
|
||||
}
|
||||
|
||||
async function unlock() {
|
||||
|
||||
Reference in New Issue
Block a user