feat(desktop): two-way cloud sync with mobile and web
Rewrites the desktop mirror as services/sync/SyncEngine: a persistent outbox, per-account server-clock keyset cursors with paging, pulls that never overwrite unsent local edits, deletions both ways through sync_tombstones and per-row failure isolation. It now covers history titles and favorites, dictionary, every meeting's memos and documents, memo tags, user commands and dictation/meeting templates, and registers the desktop as a device that the phone can disconnect. Fixes shipped defects: the first pull after sign-in fetched nothing, only the first meeting's children were pushed, team meetings leaked into the personal database and lost team_id on re-push, and Realtime never connected because Electron's Node 20 has no global WebSocket (ws is now the transport). Anonymous local-mode records are imported into the first account that signs in. The settings sync section is translated and shows pending/rejected changes; synced screens reload on app:dataChanged.
This commit is contained in:
parent
b5c9ff9f31
commit
0a4f5aee64
49 changed files with 3940 additions and 1033 deletions
|
|
@ -5,6 +5,7 @@
|
|||
import { EventEmitter } from 'events'
|
||||
import Store from 'electron-store'
|
||||
import { getLogger } from './LoggerService'
|
||||
import { getCloudSyncService } from './CloudSyncService'
|
||||
import { getMainWindow } from '../windows/WindowManager'
|
||||
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
|
||||
import { D3ROError, ErrorCode } from '@d3ro/core/errors'
|
||||
|
|
@ -113,6 +114,7 @@ class DictationTemplateService extends EventEmitter {
|
|||
const templates = this.getAll()
|
||||
templates.push(template)
|
||||
this._store.set('templates', templates)
|
||||
getCloudSyncService().pushOne('user_templates', template.id)
|
||||
|
||||
return template
|
||||
}
|
||||
|
|
@ -136,6 +138,7 @@ class DictationTemplateService extends EventEmitter {
|
|||
|
||||
templates[idx] = updated
|
||||
this._store.set('templates', templates)
|
||||
if (!updated.isBuiltin) getCloudSyncService().pushOne('user_templates', updated.id)
|
||||
return updated
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +156,26 @@ class DictationTemplateService extends EventEmitter {
|
|||
'templates',
|
||||
templates.filter((t) => t.id !== id),
|
||||
)
|
||||
getCloudSyncService().pushDelete('user_templates', id)
|
||||
}
|
||||
|
||||
/** 동기화: 다른 기기의 사용자 템플릿을 반영한다. outbox에 다시 넣지 않는다. */
|
||||
applyRemote(template: DictationTemplate): void {
|
||||
const templates = this.getAll()
|
||||
const idx = templates.findIndex((t) => t.id === template.id)
|
||||
if (idx === -1) templates.push(template)
|
||||
else if (!templates[idx].isBuiltin) templates[idx] = template
|
||||
else return
|
||||
this._store.set('templates', templates)
|
||||
}
|
||||
|
||||
/** 동기화: 다른 기기에서 지운 사용자 템플릿을 지운다. */
|
||||
removeRemote(id: string): boolean {
|
||||
const templates = this.getAll()
|
||||
const target = templates.find((t) => t.id === id)
|
||||
if (!target || target.isBuiltin) return false
|
||||
this._store.set('templates', templates.filter((t) => t.id !== id))
|
||||
return true
|
||||
}
|
||||
|
||||
// ── 세션 관리 ──
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue