final update

This commit is contained in:
bagus-arie05
2025-11-11 14:23:30 +07:00
parent 1733c67b9e
commit 783f143902
9 changed files with 202 additions and 137 deletions

View File

@@ -124,6 +124,39 @@ export function useFileSync() {
}
// const tampilFileBrowser = async () => {
// await syncFiles();
// if (isSyncing.value) {
// try {
// const localStoreKeys = await localStore.keys()
// // console.log('localStore Keys:', localStoreKeys)
// const files: { name: string; blob: Blob; type: string; url: string }[] = []
// for (const key of localStoreKeys) {
// if (!key.endsWith('-meta')) {
// const fileBlob = await localStore.getItem<Blob>(key)
// if (fileBlob instanceof Blob) {
// const url = URL.createObjectURL(fileBlob)
// files.push({ name: key, blob: fileBlob, type: fileBlob.type, url: url })
// }
// }
// }
// // console.log('Files in IndexedDB:',fileLocal.value)
// return fileLocal.value = files
// } catch (err) {
// console.error('Gagal memuat file dari IndexedDB:', err)
// } finally {
// isSyncing.value = false
// }
// }
// }
const tampilFileBrowser = async () => {
await syncFiles();
@@ -144,7 +177,16 @@ export function useFileSync() {
}
}
}
// console.log('Files in IndexedDB:',fileLocal.value)
// console.log('Files in IndexedDB:',files)
// console.log('File Server:', fileServer.value)
const fileTidaksama = files.filter(local => !fileServer.value.some(fs => fs.name === local.name))
// console.log('File tidak sama dengan server:', fileTidaksama)
for (const namaFile of fileTidaksama) {
const firstNamePart = namaFile.name.split('.')[0];
console.log('file lokal yang tidak ada di server:', firstNamePart);
await removeFiles(firstNamePart)
}
return fileLocal.value = files
} catch (err) {
@@ -156,7 +198,6 @@ export function useFileSync() {
}
}
// Bersihkan object URL biar gak bocor memori
onBeforeUnmount(() => {
fileLocal.value.forEach(f => URL.revokeObjectURL(f.url))