evader for preset
This commit is contained in:
@@ -103,7 +103,10 @@ export const PresetThumbnailGenerator = () => {
|
|||||||
body: blob,
|
body: blob,
|
||||||
headers: { 'Content-Type': 'image/png' },
|
headers: { 'Content-Type': 'image/png' },
|
||||||
})
|
})
|
||||||
if (!res.ok) {
|
if (res.ok) {
|
||||||
|
const json = await res.json()
|
||||||
|
emitter.emit('preset:thumbnail-updated', { presetId, thumbnailUrl: json.thumbnail_url })
|
||||||
|
} else {
|
||||||
console.error('❌ PresetThumbnail: upload failed', await res.text())
|
console.error('❌ PresetThumbnail: upload failed', await res.text())
|
||||||
}
|
}
|
||||||
}, 'image/png')
|
}, 'image/png')
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import { useEffect, useState, useCallback } from 'react'
|
import { useEffect, useState, useCallback } from 'react'
|
||||||
import { BookMarked, Check, Globe, GlobeLock, Pencil, Plus, Save, Trash2, Users, X } from 'lucide-react'
|
import { BookMarked, Check, Globe, GlobeLock, Pencil, Plus, Save, Trash2, Users, X } from 'lucide-react'
|
||||||
|
import { emitter } from '@pascal-app/core'
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/primitives/popover'
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/primitives/popover'
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/primitives/tooltip'
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/primitives/tooltip'
|
||||||
import { useAuth } from '@/features/community/lib/auth/hooks'
|
import { useAuth } from '@/features/community/lib/auth/hooks'
|
||||||
@@ -76,6 +77,16 @@ export function PresetsPopover({ type, onApply, onSave, onOverwrite, children }:
|
|||||||
if (!isAuthenticated && tab === 'mine') setTab('community')
|
if (!isAuthenticated && tab === 'mine') setTab('community')
|
||||||
}, [isAuthenticated, tab])
|
}, [isAuthenticated, tab])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const handler = ({ presetId, thumbnailUrl }: { presetId: string; thumbnailUrl: string }) => {
|
||||||
|
setPresets((prev) =>
|
||||||
|
prev.map((p) => (p.id === presetId ? { ...p, thumbnail_url: thumbnailUrl } : p)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
emitter.on('preset:thumbnail-updated', handler)
|
||||||
|
return () => emitter.off('preset:thumbnail-updated', handler)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const handleSaveNew = async () => {
|
const handleSaveNew = async () => {
|
||||||
if (!saveName.trim()) return
|
if (!saveName.trim()) return
|
||||||
setSaving(true)
|
setSaving(true)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ type ToolEvents = {
|
|||||||
|
|
||||||
type PresetEvents = {
|
type PresetEvents = {
|
||||||
'preset:generate-thumbnail': { presetId: string; nodeId: string }
|
'preset:generate-thumbnail': { presetId: string; nodeId: string }
|
||||||
|
'preset:thumbnail-updated': { presetId: string; thumbnailUrl: string }
|
||||||
}
|
}
|
||||||
|
|
||||||
type EditorEvents = GridEvents &
|
type EditorEvents = GridEvents &
|
||||||
|
|||||||
Reference in New Issue
Block a user