Refactor useVersions to @tanstack/react-query (#114)

working
This commit is contained in:
Will Chen
2025-05-08 22:04:20 -07:00
committed by GitHub
parent cb9ffcc550
commit 34ac9df743
5 changed files with 105 additions and 68 deletions

View File

@@ -21,17 +21,20 @@ export function VersionPane({ isVisible, onClose }: VersionPaneProps) {
selectedVersionIdAtom,
);
useEffect(() => {
// Refresh versions in case the user updated versions outside of the app
// (e.g. manually using git).
// Avoid loading state which causes brief flash of loading state.
refreshVersions();
if (!isVisible && selectedVersionId) {
setSelectedVersionId(null);
IpcClient.getInstance().checkoutVersion({
appId: appId!,
versionId: "main",
});
async function updateVersions() {
// Refresh versions in case the user updated versions outside of the app
// (e.g. manually using git).
// Avoid loading state which causes brief flash of loading state.
if (!isVisible && selectedVersionId) {
setSelectedVersionId(null);
await IpcClient.getInstance().checkoutVersion({
appId: appId!,
versionId: "main",
});
}
refreshVersions();
}
updateVersions();
}, [isVisible, refreshVersions]);
if (!isVisible) {
return null;