Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cmds): path in changing app dir call #591

Merged
merged 2 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion src/components/setting/setting-verge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DialogRef } from "@/components/base";
import { useMessage } from "@/hooks/use-notification";
import { useMessage, useNotification } from "@/hooks/use-notification";
import { useVerge } from "@/hooks/use-verge";
import {
collectLogs,
Expand All @@ -9,6 +9,7 @@ import {
openLogsDir,
setCustomAppDir,
} from "@/services/cmds";
import { sleep } from "@/utils";
import getSystem from "@/utils/get-system";
import { ArrowForward, IosShare, Settings } from "@mui/icons-material";
import {
Expand All @@ -22,6 +23,7 @@ import {
} from "@mui/material";
import { version } from "@root/package.json";
import { open } from "@tauri-apps/api/dialog";
import { relaunch } from "@tauri-apps/api/process";
import { checkUpdate } from "@tauri-apps/api/updater";
import { useAsyncEffect, useLockFn } from "ahooks";
import { useRef, useState } from "react";
Expand Down Expand Up @@ -116,6 +118,12 @@ const SettingVerge = ({ onError }: Props) => {
return;
}
await setCustomAppDir(selected);
useNotification({
title: t("Success"),
body: t("App directory changed successfully"),
});
await sleep(1000);
await relaunch();
} catch (err: any) {
useMessage(err.message || err.toString(), {
title: t("Error"),
Expand Down
4 changes: 2 additions & 2 deletions src/services/cmds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,6 @@ export async function getCustomAppDir() {
return invoke<string | null>("get_custom_app_dir");
}

export async function setCustomAppDir(dir: string) {
return invoke<void>("set_custom_app_dir", { dir });
export async function setCustomAppDir(path: string) {
return invoke<void>("set_custom_app_dir", { path });
}
4 changes: 4 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
export function classNames(...classes: any[]) {
return classes.filter(Boolean).join(" ");
}

export async function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
Loading