One-click backups for AT Protocol
1import { invoke } from "@tauri-apps/api/core";
2import { listen } from "@tauri-apps/api/event";
3import { toast } from "sonner";
4
5export class BackgroundTestService {
6 static async testBackgroundBackup() {
7 try {
8 // Test the background scheduler
9 await invoke("start_background_scheduler");
10 toast("Background scheduler started");
11
12 // Listen for backup events
13 await listen("perform-backup", () => {
14 toast("Background backup event received!");
15 console.log("Background backup event received");
16 });
17
18 console.log("Background test service initialized");
19 } catch (error) {
20 console.error("Background test failed:", error);
21 toast("Background test failed");
22 }
23 }
24
25 static async triggerTestBackup() {
26 try {
27 // Emit a test backup event
28 await invoke("emit", { event: "perform-backup", payload: null });
29 toast("Test backup event triggered");
30 } catch (error) {
31 console.error("Failed to trigger test backup:", error);
32 toast("Failed to trigger test backup");
33 }
34 }
35}