Skip to content

Commit

Permalink
fix(tauri): check autostart status to prevent error with `@tauri-apps…
Browse files Browse the repository at this point in the history
…/plugin-autostart` on Windows
  • Loading branch information
dubisdev authored and sekwah41 committed Nov 17, 2023
1 parent b893da4 commit de4f8b9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/renderer/src/contexts/connectors/TauriConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import {
} from "@pomatez/shareables";
import { encodeSvg } from "../../utils";
import { TraySVG } from "../../components";
import { enable, disable } from "@tauri-apps/plugin-autostart";
import {
enable,
disable,
isEnabled,
} from "@tauri-apps/plugin-autostart";
import { invoke } from "@tauri-apps/api/primitives";
import { listen } from "@tauri-apps/api/event";
import { open } from "@tauri-apps/plugin-shell";
Expand Down Expand Up @@ -92,7 +96,13 @@ export const TauriConnectorProvider: React.FC = ({ children }) => {
if (settings.openAtLogin) {
enable().catch((err) => console.error(err));
} else {
disable().catch((err) => console.error(err));
// The autostart-plugin fails when trying to disble if it is already disabled
// https://github.com/tauri-apps/plugins-workspace/issues/24#issuecomment-1528958008
isEnabled()
.then((enabled) => {
if (enabled) disable().catch((err) => console.error(err));
})
.catch((err) => console.error(err));
}
}, [settings.openAtLogin]);

Expand Down

0 comments on commit de4f8b9

Please sign in to comment.