@@ -27,12 +27,12 @@ const deleteOpen = ref(false)
2727const renameOpen = ref (false )
2828const newName = ref (' ' )
2929const busy = ref (false )
30- const notice = ref <{ kind : ' success ' | ' error ' , message : string } | null >(null )
30+ const errorNotice = ref <string | null >(null )
3131
3232watch (() => props .asset .path , (path ) => {
3333 imageMeta .value = null
3434 textContent .value = null
35- notice .value = null
35+ errorNotice .value = null
3636 const rpc = props .rpc
3737 if (! rpc )
3838 return
@@ -57,50 +57,50 @@ const aspectRatio = computed(() => {
5757const snippets = computed (() => buildSnippets (props .asset , imageMeta .value ))
5858const supportsPreview = computed (() => SUPPORTS_PREVIEW .has (props .asset .type ))
5959
60- async function withNotice (fn : () => Promise <void >, successMessage : string ): Promise <void > {
60+ async function runAction (fn : () => Promise <void >): Promise <void > {
6161 if (! props .rpc )
6262 return
63+ errorNotice .value = null
6364 busy .value = true
6465 try {
6566 await fn ()
66- notice .value = { kind: ' success' , message: successMessage }
6767 }
6868 catch (cause ) {
69- notice .value = { kind: ' error ' , message: cause instanceof Error ? cause .message : String (cause ) }
69+ errorNotice .value = cause instanceof Error ? cause .message : String (cause )
7070 }
7171 finally {
7272 busy .value = false
7373 }
7474}
7575
7676async function handleDelete(): Promise <void > {
77- await withNotice (async () => {
77+ await runAction (async () => {
7878 await props .rpc ! .call (' devframes:plugin:assets:delete' , { paths: [props .asset .path ] })
7979 deleteOpen .value = false
8080 emit (' changed' )
8181 emit (' close' )
82- }, ' Deleted ' )
82+ })
8383}
8484
8585async function handleRename(): Promise <void > {
86- await withNotice (async () => {
86+ await runAction (async () => {
8787 await props .rpc ! .call (' devframes:plugin:assets:rename' , { path: props .asset .path , newName: newName .value })
8888 renameOpen .value = false
8989 emit (' changed' )
9090 emit (' close' )
91- }, ' Renamed ' )
91+ })
9292}
9393
9494async function handleOpenInEditor(): Promise <void > {
95- await withNotice (async () => {
95+ await runAction (async () => {
9696 await props .rpc ! .call (' devframes:plugin:assets:open-in-editor' , props .asset .path )
97- }, ' Opened in editor ' )
97+ })
9898}
9999
100100async function handleRevealInFolder(): Promise <void > {
101- await withNotice (async () => {
101+ await runAction (async () => {
102102 await props .rpc ! .call (' devframes:plugin:assets:reveal-in-folder' , props .asset .path )
103- }, ' Revealed in folder manager ' )
103+ })
104104}
105105
106106function openRenameDialog(): void {
@@ -206,8 +206,8 @@ function openInBrowser(): void {
206206 </ActionButton >
207207 </div >
208208
209- <div v-if =" notice " class =" text-xs" :class = " notice.kind === 'error' ? ' text-error' : 'text-success' " >
210- {{ notice.message }}
209+ <div v-if =" errorNotice " class =" text-xs text-error" >
210+ {{ errorNotice }}
211211 </div >
212212
213213 <div class =" flex-1" />
0 commit comments