experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(cmd): add Sync now command for manual sync trigger

+62
+2
extensions/cmd/commands/index.js
··· 10 10 import urlModule from './url.js'; 11 11 import historyModule from './history.js'; 12 12 import tagModule from './tag.js'; 13 + import syncCommand from './sync.js'; 13 14 14 15 // Chaining commands - for command composition pipelines 15 16 import listsCommand from './lists.js'; ··· 36 37 openCommand, 37 38 debugCommand, 38 39 modalCommand, 40 + syncCommand, 39 41 ...noteModule.commands, 40 42 ...tagsetModule.commands, 41 43 ...urlModule.commands,
+60
extensions/cmd/commands/sync.js
··· 1 + /** 2 + * Sync command - manually trigger a full bidirectional sync 3 + */ 4 + 5 + const api = window.app; 6 + 7 + export default { 8 + name: 'Sync now', 9 + description: 'Trigger manual sync with server', 10 + 11 + execute: async () => { 12 + console.log('[sync] Triggering manual sync...'); 13 + 14 + // Check if sync API is available 15 + if (!api?.sync?.syncAll) { 16 + console.error('[sync] Sync API not available'); 17 + return { 18 + success: false, 19 + error: 'Sync API not available' 20 + }; 21 + } 22 + 23 + try { 24 + const result = await api.sync.syncAll(); 25 + 26 + if (result.success) { 27 + const { pulled, pushed, conflicts } = result.data || {}; 28 + console.log('[sync] Sync completed:', result.data); 29 + 30 + let message = 'Sync completed'; 31 + const details = []; 32 + if (pulled) details.push(`${pulled} pulled`); 33 + if (pushed) details.push(`${pushed} pushed`); 34 + if (conflicts) details.push(`${conflicts} conflicts`); 35 + if (details.length) message += `: ${details.join(', ')}`; 36 + 37 + return { 38 + success: true, 39 + command: 'sync', 40 + message, 41 + data: result.data 42 + }; 43 + } else { 44 + console.error('[sync] Sync failed:', result.error); 45 + return { 46 + success: false, 47 + command: 'sync', 48 + error: result.error || 'Sync failed' 49 + }; 50 + } 51 + } catch (err) { 52 + console.error('[sync] Error during sync:', err); 53 + return { 54 + success: false, 55 + command: 'sync', 56 + error: err.message 57 + }; 58 + } 59 + } 60 + };