Skip to content

Commit f47206c

Browse files
committed
refactor(snippets): use new api method in getSnippets
1 parent 3a2f1fb commit f47206c

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/renderer/store/snippets.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,9 @@ export const useSnippetStore = defineStore('snippets', {
6666

6767
actions: {
6868
async getSnippets () {
69-
// Почему то не работает _expand
70-
const { data } = await useApi('/snippets?_expand=folder`').get().json()
71-
const { data: folderData } = await useApi('/folders').get().json()
72-
73-
// Поэтому добавляем folder самостоятельно
74-
this.all = data.value.map((i: SnippetWithFolder) => {
75-
const folder = folderData.value.find((f: Folder) => f.id === i.folderId)
76-
if (folder) i.folder = folder
77-
return i
78-
})
69+
const { data } = await useApi('/snippets/embed-folder').get().json()
7970

71+
this.all = data.value
8072
this.all.sort((a, b) => (a.updatedAt > b.updatedAt ? -1 : 1))
8173
},
8274
async getSnippetsByFolderIds (ids: string[]) {

0 commit comments

Comments
 (0)