diff --git a/js/accounts/pocketbase.js b/js/accounts/pocketbase.js index 53e22d8..1e221c7 100644 --- a/js/accounts/pocketbase.js +++ b/js/accounts/pocketbase.js @@ -18,10 +18,8 @@ const syncManager = { _isSyncing: false, async _getUserRecord(uid) { - if (!uid) { - console.warn('_getUserRecord called with no UID.'); - return null; - } + if (!uid) return null; + if (this._userRecordCache && this._userRecordCache.firebase_id === uid) { return this._userRecordCache; } @@ -46,11 +44,11 @@ const syncManager = { this._userRecordCache = newRecord; return newRecord; } catch (createError) { - console.error('Failed to create user record in PocketBase:', createError); + console.error('[PocketBase] Failed to create user:', createError); return null; } } - console.error('Failed to get user record from PocketBase:', error); + console.error('[PocketBase] Failed to get user:', error); return null; } }, @@ -567,10 +565,10 @@ const syncManager = { window.dispatchEvent(new CustomEvent('history-changed')); window.dispatchEvent(new HashChangeEvent('hashchange')); - console.log('[PocketBase] ✓ Sync completed successfully'); + console.log('[PocketBase] ✓ Sync completed'); } } catch (error) { - console.error('Error during PocketBase sync!', error); + console.error('[PocketBase] Sync error:', error); } finally { this._isSyncing = false; }