mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 09:06:42 +02:00
feat(todo): wire up browser sync with Go server
- Auth store starts/stops sync on login/logout - LocalStore queues all existing records for initial sync (guest→auth transition) - LocalCollection.queueAllForSync() creates pending inserts for all local records - Skips initial queue if sync cursor exists (already synced before) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8f56feb115
commit
b85c32fcce
3 changed files with 62 additions and 1 deletions
|
|
@ -6,6 +6,7 @@
|
|||
import { browser } from '$app/environment';
|
||||
import { initializeWebAuth, type UserData } from '@manacore/shared-auth';
|
||||
import { apiClient } from '$lib/api/client';
|
||||
import { todoStore } from '$lib/data/local-store';
|
||||
|
||||
// Default URLs for local development only
|
||||
const DEV_AUTH_URL = 'http://localhost:3001';
|
||||
|
|
@ -221,6 +222,9 @@ export const authStore = {
|
|||
apiClient.setAccessToken(token);
|
||||
}
|
||||
|
||||
// Start syncing local data to server
|
||||
todoStore.startSync(() => authStore.getValidToken());
|
||||
|
||||
return { success: true };
|
||||
} catch (error) {
|
||||
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
||||
|
|
@ -264,6 +268,9 @@ export const authStore = {
|
|||
* Sign out
|
||||
*/
|
||||
async signOut() {
|
||||
// Stop syncing before clearing auth
|
||||
todoStore.stopSync();
|
||||
|
||||
const authService = getAuthService();
|
||||
if (!authService) {
|
||||
user = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue