fix: more resilient saved to avoid conflict. (no need to add the README main file when saveCacheNote)
This commit is contained in:
@@ -40,7 +40,6 @@ export const useFile = (sha: Ref<string> | string, retrieveContent = true) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getCachedFileContent = async (): Promise<string | null> => {
|
const getCachedFileContent = async (): Promise<string | null> => {
|
||||||
debugger
|
|
||||||
const cachedNote = await getCachedNote()
|
const cachedNote = await getCachedNote()
|
||||||
|
|
||||||
fromCache.value = !!cachedNote
|
fromCache.value = !!cachedNote
|
||||||
|
|||||||
10
src/modules/note/cache/prepareNoteCache.ts
vendored
10
src/modules/note/cache/prepareNoteCache.ts
vendored
@@ -33,10 +33,12 @@ export const prepareNoteCache = (sha: string, path?: string) => {
|
|||||||
editedSha: params?.editedSha
|
editedSha: params?.editedSha
|
||||||
}
|
}
|
||||||
|
|
||||||
store.addFile({
|
if (params && params.path) {
|
||||||
path: params?.path,
|
store.addFile({
|
||||||
sha: params?.editedSha
|
path: params.path,
|
||||||
})
|
sha: params.editedSha
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
await data.update(newNote)
|
await data.update(newNote)
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,18 @@ export const useUserRepoStore = defineStore({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
addFile(file: RepoFile) {
|
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(
|
const savedRepoId = data.generateId(
|
||||||
DataType.SavedRepo,
|
DataType.SavedRepo,
|
||||||
`${this.user}-${this.repo}`
|
`${this.user}-${this.repo}`
|
||||||
|
|||||||
Reference in New Issue
Block a user