From 4cfb0277217f322d925265a5ceeda4d404a70490 Mon Sep 17 00:00:00 2001 From: Samidy Date: Tue, 20 Jan 2026 00:11:57 +0300 Subject: [PATCH] chud --- js/accounts/pocketbase.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/js/accounts/pocketbase.js b/js/accounts/pocketbase.js index 4571ce9..d0bbace 100644 --- a/js/accounts/pocketbase.js +++ b/js/accounts/pocketbase.js @@ -396,14 +396,27 @@ const syncManager = { const cloudData = await this.getUserData(); if (cloudData) { + let database = db; + if (typeof database === 'function') { + database = await database(); + } else { + database = await database; + } + + const getAll = async (store) => { + if (database && typeof database.getAll === 'function') return database.getAll(store); + if (database && database.db && typeof database.db.getAll === 'function') return database.db.getAll(store); + return []; + }; + const localData = { - tracks: (await db.getAll('favorites_tracks')) || [], - albums: (await db.getAll('favorites_albums')) || [], - artists: (await db.getAll('favorites_artists')) || [], - playlists: (await db.getAll('favorites_playlists')) || [], - mixes: (await db.getAll('favorites_mixes')) || [], - history: (await db.getAll('history_tracks')) || [], - userPlaylists: (await db.getAll('user_playlists')) || [], + tracks: (await getAll('favorites_tracks')) || [], + albums: (await getAll('favorites_albums')) || [], + artists: (await getAll('favorites_artists')) || [], + playlists: (await getAll('favorites_playlists')) || [], + mixes: (await getAll('favorites_mixes')) || [], + history: (await getAll('history_tracks')) || [], + userPlaylists: (await getAll('user_playlists')) || [], }; let { library, history, userPlaylists } = cloudData; @@ -474,7 +487,7 @@ const syncManager = { user_playlists: Object.values(userPlaylists).filter((p) => p && typeof p === 'object'), }; - await db.importData(convertedData); + await database.importData(convertedData); await new Promise((resolve) => setTimeout(resolve, 300)); window.dispatchEvent(new CustomEvent('library-changed'));