diff --git a/src/hooks/useFile.hook.ts b/src/hooks/useFile.hook.ts index e93b7b1..3299bd7 100644 --- a/src/hooks/useFile.hook.ts +++ b/src/hooks/useFile.hook.ts @@ -40,7 +40,6 @@ export const useFile = (sha: Ref | string, retrieveContent = true) => { } const getCachedFileContent = async (): Promise => { - debugger const cachedNote = await getCachedNote() fromCache.value = !!cachedNote diff --git a/src/modules/note/cache/prepareNoteCache.ts b/src/modules/note/cache/prepareNoteCache.ts index 33b4442..c655773 100644 --- a/src/modules/note/cache/prepareNoteCache.ts +++ b/src/modules/note/cache/prepareNoteCache.ts @@ -33,10 +33,12 @@ export const prepareNoteCache = (sha: string, path?: string) => { editedSha: params?.editedSha } - store.addFile({ - path: params?.path, - sha: params?.editedSha - }) + if (params && params.path) { + store.addFile({ + path: params.path, + sha: params.editedSha + }) + } await data.update(newNote) diff --git a/src/modules/repo/store/userRepo.store.ts b/src/modules/repo/store/userRepo.store.ts index db9e8f2..e6fbae3 100644 --- a/src/modules/repo/store/userRepo.store.ts +++ b/src/modules/repo/store/userRepo.store.ts @@ -91,6 +91,18 @@ export const useUserRepoStore = defineStore({ }) }, addFile(file: RepoFile) { + if (!file.sha) { + return + } + + const doesFileExist = this.files.some((f) => f.sha === file.sha) + + if (doesFileExist) { + return + } + + console.log('add file') + const savedRepoId = data.generateId( DataType.SavedRepo, `${this.user}-${this.repo}`