refactor(dry-F2): centralize shared UI primitives (relative-time, toast, download-status)
- utils/date.js: add formatRelative(iso, {future,nullText}); migrate 6 sites
(SourceRow, SubscriptionsTab, SourceHealthDot, SchedulerStatusBar +
thin adapters in BackupRunsTable/SystemActivityTab for their '—' null text).
PostCard (30d->absolute) and CredentialCard (mo/y buckets) intentionally
keep bespoke formatters.
- utils/toast.js: toast(opts) wraps the globalThis.window?.__fcToast?.(...)
incantation; migrate 63 call sites across 24 files.
- utils/downloadStatus.js: single source for the download-event status enum
-> label/color/icon; collapse the 3 duplicate maps (DownloadStatChips,
DownloadsFilterPopover, DownloadEventRow).
Net -33 lines. Platform metadata was already centralized in platformColor.js.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { toast } from '../utils/toast.js'
|
||||
import { ref, computed } from 'vue'
|
||||
import { useApi } from '../composables/useApi.js'
|
||||
|
||||
@@ -51,7 +52,7 @@ export const useGallerySelectionStore = defineStore('gallerySelection', () => {
|
||||
body: { image_ids: order.value, tag_id: tagId, source }
|
||||
})
|
||||
await refresh()
|
||||
globalThis.window?.__fcToast?.({
|
||||
toast({
|
||||
text: `Added to ${body.added_count} image(s)`, type: 'success'
|
||||
})
|
||||
return body
|
||||
@@ -62,7 +63,7 @@ export const useGallerySelectionStore = defineStore('gallerySelection', () => {
|
||||
body: { image_ids: order.value, tag_id: tagId }
|
||||
})
|
||||
await refresh()
|
||||
globalThis.window?.__fcToast?.({
|
||||
toast({
|
||||
text: `Removed from ${body.removed_count} image(s)`, type: 'success'
|
||||
})
|
||||
return body
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { toast } from '../utils/toast.js'
|
||||
import { ref, computed } from 'vue'
|
||||
import { useApi } from '../composables/useApi.js'
|
||||
|
||||
@@ -37,7 +38,7 @@ export const useImportStore = defineStore('import', () => {
|
||||
settings.value = await api.patch('/api/settings/import', { body: patch })
|
||||
} catch (e) {
|
||||
settingsError.value = e.message
|
||||
window.__fcToast?.({ text: `Settings save failed: ${e.message}`, type: 'error' })
|
||||
toast({ text: `Settings save failed: ${e.message}`, type: 'error' })
|
||||
throw e
|
||||
}
|
||||
}
|
||||
@@ -68,7 +69,7 @@ export const useImportStore = defineStore('import', () => {
|
||||
const label = mode === 'deep'
|
||||
? 'Deep scan triggered (re-applying sidecar metadata + filling NULL phash/artist on existing rows)'
|
||||
: mode === 'verify' ? 'Library verify triggered' : 'Quick scan triggered'
|
||||
window.__fcToast?.({ text: label, type: 'success' })
|
||||
toast({ text: label, type: 'success' })
|
||||
await refreshStatus()
|
||||
// Re-poll twice over ~5s and produce an HONEST follow-up toast.
|
||||
// Operator-flagged 2026-05-25: the prior "no new files" message was
|
||||
@@ -91,22 +92,22 @@ export const useImportStore = defineStore('import', () => {
|
||||
const refreshedCount = sameBatch.filter(t => t.status === 'complete' && t.result_image_id).length
|
||||
const newImported = sameBatch.filter(t => t.status === 'complete' && t.result_image_id && !t.error).length
|
||||
if (mode === 'deep' && sameBatch.length > 0) {
|
||||
window.__fcToast?.({
|
||||
toast({
|
||||
text: `Deep scan finished — ${sameBatch.length} file(s) processed`,
|
||||
type: 'info',
|
||||
})
|
||||
} else if (mode === 'quick' && sameBatch.length > 0) {
|
||||
window.__fcToast?.({
|
||||
toast({
|
||||
text: `Quick scan finished — ${newImported} new file(s) queued`,
|
||||
type: 'info',
|
||||
})
|
||||
} else {
|
||||
window.__fcToast?.({ text: 'Library is up to date', type: 'info' })
|
||||
toast({ text: 'Library is up to date', type: 'info' })
|
||||
}
|
||||
}, 2000)
|
||||
} catch (e) {
|
||||
triggerError.value = e.message
|
||||
window.__fcToast?.({ text: `Scan failed: ${e.message}`, type: 'error' })
|
||||
toast({ text: `Scan failed: ${e.message}`, type: 'error' })
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { toast } from '../utils/toast.js'
|
||||
import { ref, computed } from 'vue'
|
||||
import { useApi } from '../composables/useApi.js'
|
||||
|
||||
@@ -96,7 +97,7 @@ export const useModalStore = defineStore('modal', () => {
|
||||
})
|
||||
} catch (e) {
|
||||
current.value.tags = prev
|
||||
window.__fcToast?.({ text: `Failed to remove tag: ${e.message}`, type: 'error' })
|
||||
toast({ text: `Failed to remove tag: ${e.message}`, type: 'error' })
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { toast } from '../utils/toast.js'
|
||||
import { ref } from 'vue'
|
||||
import { useApi } from '../composables/useApi.js'
|
||||
|
||||
@@ -59,7 +60,7 @@ export const useSeriesManageStore = defineStore('seriesManage', () => {
|
||||
})
|
||||
pickerSelection.value = []
|
||||
await refresh()
|
||||
globalThis.window?.__fcToast?.({ text: 'Added to series', type: 'success' })
|
||||
toast({ text: 'Added to series', type: 'success' })
|
||||
}
|
||||
|
||||
async function remove(imageId) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { toast } from '../utils/toast.js'
|
||||
import { ref } from 'vue'
|
||||
import { useApi } from '../composables/useApi.js'
|
||||
|
||||
@@ -54,7 +55,7 @@ export const useSuggestionsStore = defineStore('suggestions', () => {
|
||||
body: { tag_id: tagId }
|
||||
})
|
||||
_drop(suggestion.category, s => s === suggestion)
|
||||
window.__fcToast?.({
|
||||
toast({
|
||||
text: `Tagged: ${suggestion.display_name}`,
|
||||
type: 'success'
|
||||
})
|
||||
@@ -69,7 +70,7 @@ export const useSuggestionsStore = defineStore('suggestions', () => {
|
||||
}
|
||||
})
|
||||
_drop(suggestion.category, s => s === suggestion)
|
||||
window.__fcToast?.({
|
||||
toast({
|
||||
text: `Aliased & tagged: ${suggestion.display_name}`,
|
||||
type: 'success'
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user