Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/pages/install/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

type Permission = PermissionItem[];

let closingWindow = false;
const closeWindow = (doBackwards: boolean) => {
if (doBackwards) {
history.go(-1);
Expand Down Expand Up @@ -314,7 +315,9 @@
};

useEffect(() => {
closingWindow = false; // reset
!loaded && initAsync();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [searchParams, loaded]);

const [watchFile, setWatchFile] = useState(false);
Expand Down Expand Up @@ -455,6 +458,7 @@
};

const handleInstall = async (options: { closeAfterInstall?: boolean; noMoreUpdates?: boolean } = {}) => {
if (closingWindow) return;
if (!upsertScript) {
Message.error(t("script_info_load_failed")!);
return;
Expand Down Expand Up @@ -498,22 +502,31 @@
}

if (shouldClose) {
setTimeout(() => {
closeWindow(doBackwards);
}, 500);
if (!closingWindow) {
closingWindow = true;
setTimeout(() => {
closeWindow(doBackwards);
}, 500);
}
}
} catch (e) {
const errorMessage = scriptInfo?.userSubscribe ? t("subscribe_failed") : t("install_failed");
Message.error(`${errorMessage}: ${e}`);
}
};

const handleClose = (options?: { noMoreUpdates: boolean }) => {
const handleClose = async (options?: { noMoreUpdates: boolean }) => {
if (closingWindow) return;
const { noMoreUpdates = false } = options || {};
if (noMoreUpdates && scriptInfo && !scriptInfo.userSubscribe) {
scriptClient.setCheckUpdateUrl(scriptInfo.uuid, false);
await scriptClient.setCheckUpdateUrl(scriptInfo.uuid, false);
}
if (!closingWindow) {
closingWindow = true;
setTimeout(() => {
closeWindow(doBackwards);
}, 50);
}
closeWindow(doBackwards);
};

const {
Expand Down Expand Up @@ -630,7 +643,7 @@
return () => {
unmountFileTrack(handle);
};
}, [memoWatchFile]);

Check warning on line 646 in src/pages/install/App.tsx

View workflow job for this annotation

GitHub Actions / Run tests

React Hook useEffect has missing dependencies: 'localFileHandle', 'scriptInfo?.uuid', 'setupWatchFile', and 'watchFile'. Either include them or remove the dependency array

// 检查是否有 uuid 或 file
const searchParamUrl = searchParams.get("url");
Expand Down
Loading