Skip to content

Commit

Permalink
fix(snippets): remove prev characters by typing name #347 (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Mar 8, 2023
1 parent ea15d51 commit ddc31e7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/renderer/store/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,21 @@ export const useSnippetStore = defineStore('snippets', {
}
},
async patchSnippetsById (id: string, body: Partial<Snippet>) {
const { data } = await useApi(`/snippets/${id}`).patch(body).json()
const snippet = this.snippets.find(i => i.id === id)

if (!snippet) return

if (snippet.id === this.selectedId) {
for (const props in data.value) {
(this.selected as any)[props] = data.value[props]
for (const props in body) {
(this.selected as any)[props] = (body as any)[props]
}
}

for (const props in data.value) {
(snippet as any)[props] = data.value[props]
for (const props in body) {
(snippet as any)[props] = (body as any)[props]
}

await useApi(`/snippets/${id}`).patch(body).json()
},
async patchCurrentSnippetContentByKey (
key: keyof SnippetContent,
Expand Down

0 comments on commit ddc31e7

Please sign in to comment.