File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ const activeTab = ref<Tab>('library')
95
95
96
96
const onClickFolder = async (id : string ) => {
97
97
folderStore .selectId (id )
98
- snippetStore .setSnippetsByFolderIds ()
98
+ await snippetStore .setSnippetsByFolderIds (true )
99
99
}
100
100
101
101
const onClickSystemFolder = (alias : SystemFolderAlias ) => {
Original file line number Diff line number Diff line change @@ -157,10 +157,14 @@ export const useSnippetStore = defineStore('snippets', {
157
157
await this . patchSnippetsById ( this . selectedId ! , body )
158
158
await this . getSnippetsById ( this . selectedId ! )
159
159
} ,
160
- async setSnippetsByFolderIds ( ) {
160
+ async setSnippetsByFolderIds ( setFirst ?: boolean ) {
161
161
const folderStore = useFolderStore ( )
162
162
await this . getSnippetsByFolderIds ( folderStore . selectedIds ! )
163
- this . snippet = this . snippets [ 0 ]
163
+
164
+ if ( setFirst ) {
165
+ this . snippet = this . snippets [ 0 ]
166
+ store . app . set ( 'selectedSnippetId' , this . snippets [ 0 ] . id )
167
+ }
164
168
} ,
165
169
setSnippetsByAlias ( alias : SystemFolderAlias ) {
166
170
const folderStore = useFolderStore ( )
@@ -192,6 +196,10 @@ export const useSnippetStore = defineStore('snippets', {
192
196
store . app . set ( 'selectedFolderAlias' , alias )
193
197
store . app . delete ( 'selectedFolderId' )
194
198
store . app . delete ( 'selectedFolderIds' )
199
+ } ,
200
+ setSnippetById ( id : string ) {
201
+ const snippet = this . all . find ( i => i . id === id )
202
+ if ( snippet ) this . snippet = snippet
195
203
}
196
204
}
197
205
} )
You can’t perform that action at this time.
0 commit comments