Initial open-source release

This commit is contained in:
Will Chen
2025-04-11 09:37:05 -07:00
commit 43f67e0739
208 changed files with 45476 additions and 0 deletions

33
src/hooks/useLoadApps.ts Normal file
View File

@@ -0,0 +1,33 @@
import { useState, useEffect, useCallback } from "react";
import { useAtom } from "jotai";
import { appBasePathAtom, appsListAtom } from "@/atoms/appAtoms";
import { IpcClient } from "@/ipc/ipc_client";
export function useLoadApps() {
const [apps, setApps] = useAtom(appsListAtom);
const [appBasePath, setAppBasePath] = useAtom(appBasePathAtom);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
const refreshApps = useCallback(async () => {
setLoading(true);
try {
const ipcClient = IpcClient.getInstance();
const appListResponse = await ipcClient.listApps();
setApps(appListResponse.apps);
setAppBasePath(appListResponse.appBasePath);
setError(null);
} catch (error) {
console.error("Error refreshing apps:", error);
setError(error instanceof Error ? error : new Error(String(error)));
} finally {
setLoading(false);
}
}, [setApps, setError, setLoading]);
useEffect(() => {
refreshApps();
}, [refreshApps]);
return { apps, loading, error, refreshApps };
}