Add onPushToCloud/onPullFromCloud handlers

cgen-920986f302d34b99aa55407d3edb1c51
This commit is contained in:
Builder.io 2025-09-18 05:01:19 +00:00
parent 26d24c4dad
commit c3b3d72037

View file

@ -389,6 +389,29 @@ export function SwitchPage() {
setIssues(await listIssues(activeRepo.id)); setIssues(await listIssues(activeRepo.id));
setSelectedIssueId(undefined); setSelectedIssueId(undefined);
} }
async function onPushToCloud() {
if (!activeRepo) return;
try {
const { pushRepoToSupabase } = await import("../../switch/sync");
await pushRepoToSupabase(activeRepo.id);
alert("Pushed to Supabase storage.");
} catch (e:any) {
alert("Cloud push failed: " + (e?.message || e));
}
}
async function onPullFromCloud() {
if (!activeRepo) return;
try {
const { pullRepoFromSupabase } = await import("../../switch/sync");
const bundle = await pullRepoFromSupabase(activeRepo.id);
if (!bundle) { alert("No bundle found."); return; }
// For now, just show summary; full import/merge logic can be added as next step
alert(`Fetched bundle exportedAt=${new Date(bundle.exportedAt).toLocaleString()}\nbranches=${bundle.branches.length}, commits=${bundle.commits.length}, issues=${bundle.issues.length}`);
} catch (e:any) {
alert("Cloud pull failed: " + (e?.message || e));
}
}
} }
async function getFileByPath(dir: FileSystemDirectoryHandle, path: string): Promise<File | undefined> { async function getFileByPath(dir: FileSystemDirectoryHandle, path: string): Promise<File | undefined> {