From 86e5d934a5ea70daa5b8ad5519663edc773e99d7 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sun, 6 Jun 2021 11:18:30 +0200 Subject: [PATCH] :bug: (backlinks) update to override backlink in db --- src/hooks/useComputeBacklinks.hook.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/hooks/useComputeBacklinks.hook.ts b/src/hooks/useComputeBacklinks.hook.ts index 19e6799..bb4c5a8 100644 --- a/src/hooks/useComputeBacklinks.hook.ts +++ b/src/hooks/useComputeBacklinks.hook.ts @@ -8,6 +8,7 @@ import { resolvePath } from '@/modules/repo/services/resolvePath' import { useUserRepoStore } from '@/modules/repo/store/userRepo.store' import { isExternalLink } from '@/utils/link' import { filenameToNoteTitle } from '@/utils/noteTitle' +import { confirmMessage } from '@/utils/notif' import { watch } from 'vue' const isMarkdown = (filename?: string) => filename?.endsWith('.md') ?? false @@ -20,6 +21,8 @@ export const useComputeBacklinks = () => { return } + let notifiedForComputation = false + const backlinks: Map = new Map() for (const file of store.files) { @@ -65,6 +68,11 @@ export const useComputeBacklinks = () => { continue } + if (!notifiedForComputation) { + notifiedForComputation = true + confirmMessage('Updating backlinks...') + } + backlinks.set(backlinkFile.sha, [ ...previousBacklinks, { @@ -84,7 +92,7 @@ export const useComputeBacklinks = () => { links: fileBacklinks } - await data.add(backlinkNote) + await data.update(backlinkNote) backlinkEventBus.emit({ fileSha: sha }) } })