File size: 972 Bytes
6111b2b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import { getCloudSyncScheduler } from "@/shared/services/cloudSyncScheduler";
import { isCloudEnabled, cleanupProviderConnections } from "@/lib/localDb";
/**
* Initialize cloud sync scheduler
* This should be called when the application starts
*/
export async function initializeCloudSync() {
try {
// Cleanup null fields from existing data
await cleanupProviderConnections();
// Create scheduler instance with default 15-minute interval
const scheduler = await getCloudSyncScheduler(null, 15);
// Start the scheduler
await scheduler.start();
return scheduler;
} catch (error) {
console.error("[CloudSync] Error initializing scheduler:", error);
throw error;
}
}
// For development/testing purposes
if (typeof require !== "undefined" && require.main === module) {
initializeCloudSync().catch((err) => console.error("[CloudSync] init failed:", err));
}
export default initializeCloudSync;
|