fix(notes): persist uploaded image to cache so it survives reload

This commit is contained in:
Julien Calixte
2026-05-25 21:29:51 +02:00
parent 299493854e
commit b87836782b
2 changed files with 28 additions and 6 deletions

View File

@@ -85,12 +85,12 @@ export const useImageUpload = ({
return null
}
if (!store.files.some((f) => f.path === targetPath)) {
store.files = [
...store.files,
{ path: targetPath, sha, type: "blob", size: file.size }
]
}
store.registerUploadedFile({
path: targetPath,
sha,
type: "blob",
size: file.size
})
return { filename }
} catch (error) {

View File

@@ -230,6 +230,28 @@ export const useUserRepoStore = defineStore("USER_REPO_STATE", {
})
this.files = newFiles
},
registerUploadedFile(file: RepoFile) {
if (!file.path) {
return
}
const savedRepoId = generateId(
DataType.SavedRepo,
`${this.user}-${this.repo}`
)
const newFiles = [
...toRaw(this.files).filter((f) => f.path !== file.path),
toRaw(file)
]
data.update<DataType.SavedRepo, SavedRepo>({
_id: savedRepoId,
$type: DataType.SavedRepo,
repo: this.repo,
user: this.user,
files: newFiles
})
this.files = newFiles
},
resetUserRepo() {
this.user = ""
this.repo = ""