Обновлен файл service worker с новой версией для кэширования. Изменена логика обработки загруженных изображений и файлов в API оффлайн-заметок, теперь возвращаются только загруженные данные вместо всех данных. Улучшена обработка данных, получаемых от сервера.

This commit is contained in:
Fovway 2025-11-05 21:47:49 +07:00
parent 7367364d93
commit 82094e46b5
2 changed files with 11 additions and 5 deletions

View File

@ -82,7 +82,7 @@ define(['./workbox-9dc17825'], (function (workbox) { 'use strict';
"revision": "3ca0b8505b4bec776b69afdba2768812" "revision": "3ca0b8505b4bec776b69afdba2768812"
}, { }, {
"url": "index.html", "url": "index.html",
"revision": "0.mib567t8mr8" "revision": "0.hpmojmu6e28"
}], {}); }], {});
workbox.cleanupOutdatedCaches(); workbox.cleanupOutdatedCaches();
workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), { workbox.registerRoute(new workbox.NavigationRoute(workbox.createHandlerBoundToURL("index.html"), {

View File

@ -630,18 +630,21 @@ export const offlineNotesApi = {
} }
); );
// Сервер возвращает объект с полем images
const uploadedImages = Array.isArray(data) ? data : (data?.images || []);
const note = await dbManager.getNote(noteId); const note = await dbManager.getNote(noteId);
if (note) { if (note) {
const updatedNote: Note = { const updatedNote: Note = {
...note, ...note,
images: [...note.images, ...data], images: [...(note.images || []), ...uploadedImages],
syncStatus: "synced", syncStatus: "synced",
}; };
await dbManager.saveNote(updatedNote); await dbManager.saveNote(updatedNote);
store.dispatch(updateNote(updatedNote)); store.dispatch(updateNote(updatedNote));
} }
return data; return uploadedImages;
} catch (error) { } catch (error) {
console.error("Error uploading images:", error); console.error("Error uploading images:", error);
throw error; throw error;
@ -724,18 +727,21 @@ export const offlineNotesApi = {
} }
); );
// Сервер возвращает объект с полем files
const uploadedFiles = Array.isArray(data) ? data : (data?.files || []);
const note = await dbManager.getNote(noteId); const note = await dbManager.getNote(noteId);
if (note) { if (note) {
const updatedNote: Note = { const updatedNote: Note = {
...note, ...note,
files: [...note.files, ...data], files: [...(note.files || []), ...uploadedFiles],
syncStatus: "synced", syncStatus: "synced",
}; };
await dbManager.saveNote(updatedNote); await dbManager.saveNote(updatedNote);
store.dispatch(updateNote(updatedNote)); store.dispatch(updateNote(updatedNote));
} }
return data; return uploadedFiles;
} catch (error) { } catch (error) {
console.error("Error uploading files:", error); console.error("Error uploading files:", error);
throw error; throw error;