lint: remove unused imports, variables, and dead code (10 fixes)
Co-Authored-By: Justin Edmund <justin@jedmund.com>
This commit is contained in:
parent
3e2336bc5c
commit
018fc67b2c
6 changed files with 5 additions and 47 deletions
|
|
@ -8,7 +8,7 @@ export interface AutoSaveStoreOptions<TPayload, TResponse = unknown> {
|
||||||
onSaved?: (res: TResponse, ctx: { prime: (payload: TPayload) => void }) => void
|
onSaved?: (res: TResponse, ctx: { prime: (payload: TPayload) => void }) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AutoSaveStore<TPayload, TResponse = unknown> {
|
export interface AutoSaveStore<TPayload> {
|
||||||
readonly status: AutoSaveStatus
|
readonly status: AutoSaveStatus
|
||||||
readonly lastError: string | null
|
readonly lastError: string | null
|
||||||
schedule: () => void
|
schedule: () => void
|
||||||
|
|
@ -36,7 +36,7 @@ export interface AutoSaveStore<TPayload, TResponse = unknown> {
|
||||||
*/
|
*/
|
||||||
export function createAutoSaveStore<TPayload, TResponse = unknown>(
|
export function createAutoSaveStore<TPayload, TResponse = unknown>(
|
||||||
opts: AutoSaveStoreOptions<TPayload, TResponse>
|
opts: AutoSaveStoreOptions<TPayload, TResponse>
|
||||||
): AutoSaveStore<TPayload, TResponse> {
|
): AutoSaveStore<TPayload> {
|
||||||
const debounceMs = opts.debounceMs ?? 2000
|
const debounceMs = opts.debounceMs ?? 2000
|
||||||
const idleResetMs = opts.idleResetMs ?? 2000
|
const idleResetMs = opts.idleResetMs ?? 2000
|
||||||
let timer: ReturnType<typeof setTimeout> | null = null
|
let timer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
|
|
||||||
|
|
@ -182,12 +182,12 @@
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/admin/debug/clear-cache', {
|
const response = await fetch('/api/admin/debug/clear-cache', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ key: albumKey })
|
body: JSON.stringify({ key: albumKey })
|
||||||
})
|
})
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const result = await response.json()
|
await response.json()
|
||||||
toast.success(`Cleared cache for "${album.name}"`)
|
toast.success(`Cleared cache for "${album.name}"`)
|
||||||
} else {
|
} else {
|
||||||
toast.error(`Failed to clear cache for "${album.name}"`)
|
toast.error(`Failed to clear cache for "${album.name}"`)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import AdminPage from './AdminPage.svelte'
|
import AdminPage from './AdminPage.svelte'
|
||||||
import AdminSegmentedControl from './AdminSegmentedControl.svelte'
|
import AdminSegmentedControl from './AdminSegmentedControl.svelte'
|
||||||
|
|
@ -9,7 +8,6 @@
|
||||||
import UnifiedMediaModal from './UnifiedMediaModal.svelte'
|
import UnifiedMediaModal from './UnifiedMediaModal.svelte'
|
||||||
import SmartImage from '../SmartImage.svelte'
|
import SmartImage from '../SmartImage.svelte'
|
||||||
import Composer from './composer'
|
import Composer from './composer'
|
||||||
import { toast } from '$lib/stores/toast'
|
|
||||||
import type { Album, Media } from '@prisma/client'
|
import type { Album, Media } from '@prisma/client'
|
||||||
import type { JSONContent } from '@tiptap/core'
|
import type { JSONContent } from '@tiptap/core'
|
||||||
|
|
||||||
|
|
@ -33,8 +31,6 @@
|
||||||
|
|
||||||
// State
|
// State
|
||||||
let isLoading = $state(mode === 'edit')
|
let isLoading = $state(mode === 'edit')
|
||||||
let isSaving = $state(false)
|
|
||||||
let validationErrors = $state<Record<string, string>>({})
|
|
||||||
let showBulkAlbumModal = $state(false)
|
let showBulkAlbumModal = $state(false)
|
||||||
let albumMedia = $state<Array<{ media: Media; displayOrder: number }>>([])
|
let albumMedia = $state<Array<{ media: Media; displayOrder: number }>>([])
|
||||||
let editorInstance = $state<{ save: () => Promise<JSONContent>; clear: () => void } | undefined>()
|
let editorInstance = $state<{ save: () => Promise<JSONContent>; clear: () => void } | undefined>()
|
||||||
|
|
@ -123,30 +119,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateForm() {
|
|
||||||
try {
|
|
||||||
albumSchema.parse({
|
|
||||||
title: formData.title,
|
|
||||||
slug: formData.slug,
|
|
||||||
location: formData.location || undefined,
|
|
||||||
year: formData.year || undefined
|
|
||||||
})
|
|
||||||
validationErrors = {}
|
|
||||||
return true
|
|
||||||
} catch (err) {
|
|
||||||
if (err instanceof z.ZodError) {
|
|
||||||
const errors: Record<string, string> = {}
|
|
||||||
err.errors.forEach((e) => {
|
|
||||||
if (e.path[0]) {
|
|
||||||
errors[e.path[0].toString()] = e.message
|
|
||||||
}
|
|
||||||
})
|
|
||||||
validationErrors = errors
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleBulkAlbumSave() {
|
async function handleBulkAlbumSave() {
|
||||||
// Reload album to get updated photo count
|
// Reload album to get updated photo count
|
||||||
if (album && mode === 'edit') {
|
if (album && mode === 'edit') {
|
||||||
|
|
@ -200,8 +172,6 @@
|
||||||
bind:value={formData.title}
|
bind:value={formData.title}
|
||||||
placeholder="Album title"
|
placeholder="Album title"
|
||||||
required
|
required
|
||||||
error={validationErrors.title}
|
|
||||||
disabled={isSaving}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
|
|
@ -209,8 +179,7 @@
|
||||||
bind:value={formData.slug}
|
bind:value={formData.slug}
|
||||||
placeholder="url-friendly-name"
|
placeholder="url-friendly-name"
|
||||||
required
|
required
|
||||||
error={validationErrors.slug}
|
disabled={mode === 'edit'}
|
||||||
disabled={isSaving || mode === 'edit'}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="form-grid">
|
<div class="form-grid">
|
||||||
|
|
@ -218,16 +187,12 @@
|
||||||
label="Location"
|
label="Location"
|
||||||
bind:value={formData.location}
|
bind:value={formData.location}
|
||||||
placeholder="e.g. Tokyo, Japan"
|
placeholder="e.g. Tokyo, Japan"
|
||||||
error={validationErrors.location}
|
|
||||||
disabled={isSaving}
|
|
||||||
/>
|
/>
|
||||||
<Input
|
<Input
|
||||||
label="Year"
|
label="Year"
|
||||||
type="text"
|
type="text"
|
||||||
bind:value={formData.year}
|
bind:value={formData.year}
|
||||||
placeholder="e.g. 2023 or 2023-2025"
|
placeholder="e.g. 2023 or 2023-2025"
|
||||||
error={validationErrors.year}
|
|
||||||
disabled={isSaving}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -235,7 +200,6 @@
|
||||||
label="Status"
|
label="Status"
|
||||||
bind:value={formData.status}
|
bind:value={formData.status}
|
||||||
options={statusOptions}
|
options={statusOptions}
|
||||||
disabled={isSaving}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -245,7 +209,6 @@
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
bind:checked={formData.showInUniverse}
|
bind:checked={formData.showInUniverse}
|
||||||
disabled={isSaving}
|
|
||||||
class="toggle-input"
|
class="toggle-input"
|
||||||
/>
|
/>
|
||||||
<div class="toggle-content">
|
<div class="toggle-content">
|
||||||
|
|
@ -302,7 +265,6 @@
|
||||||
bind:data={formData.content}
|
bind:data={formData.content}
|
||||||
placeholder="Add album content..."
|
placeholder="Add album content..."
|
||||||
onChange={handleContentUpdate}
|
onChange={handleContentUpdate}
|
||||||
editable={!isSaving}
|
|
||||||
albumId={album?.id}
|
albumId={album?.id}
|
||||||
variant="full"
|
variant="full"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { clickOutside } from '$lib/actions/clickOutside'
|
import { clickOutside } from '$lib/actions/clickOutside'
|
||||||
import Input from './Input.svelte'
|
import Input from './Input.svelte'
|
||||||
import FormField from './FormField.svelte'
|
|
||||||
import Button from './Button.svelte'
|
import Button from './Button.svelte'
|
||||||
|
|
||||||
export interface MetadataField {
|
export interface MetadataField {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@
|
||||||
aspectRatio,
|
aspectRatio,
|
||||||
required = false,
|
required = false,
|
||||||
error,
|
error,
|
||||||
allowAltText = true,
|
|
||||||
maxFileSize = 10,
|
maxFileSize = 10,
|
||||||
placeholder = 'Drag and drop an image here, or click to browse',
|
placeholder = 'Drag and drop an image here, or click to browse',
|
||||||
helpText,
|
helpText,
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@
|
||||||
import Modal from './Modal.svelte'
|
import Modal from './Modal.svelte'
|
||||||
import Composer from './composer'
|
import Composer from './composer'
|
||||||
import AdminSegmentedControl from './AdminSegmentedControl.svelte'
|
import AdminSegmentedControl from './AdminSegmentedControl.svelte'
|
||||||
import FormField from './FormField.svelte'
|
|
||||||
import Button from './Button.svelte'
|
import Button from './Button.svelte'
|
||||||
import Input from './Input.svelte'
|
import Input from './Input.svelte'
|
||||||
import UnifiedMediaModal from './UnifiedMediaModal.svelte'
|
import UnifiedMediaModal from './UnifiedMediaModal.svelte'
|
||||||
import MediaDetailsModal from './MediaDetailsModal.svelte'
|
import MediaDetailsModal from './MediaDetailsModal.svelte'
|
||||||
import SmartImage from '../SmartImage.svelte'
|
|
||||||
import type { JSONContent } from '@tiptap/core'
|
import type { JSONContent } from '@tiptap/core'
|
||||||
import type { Media } from '@prisma/client'
|
import type { Media } from '@prisma/client'
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue