Skip to content

Commit

Permalink
fix(tauri): avoid setting open at login if already set
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Nov 19, 2023
1 parent 654c4db commit 1e836ee
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions app/renderer/src/contexts/connectors/TauriConnector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,25 @@ export const TauriConnectorProvider: React.FC = ({ children }) => {
}, []);

useEffect(() => {
if (settings.openAtLogin) {
enable().catch((err) => console.error(err));
} else {
// 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));
}
// 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 (settings.openAtLogin) {
if (!enabled)
enable()
.then(() => {
console.log("Enabled autostart");
})
.catch((err) => console.error(err));
} else {
if (enabled)
disable()
.then(() => {
console.log("Disabled autostart");
})
.catch((err) => console.error(err));
}
});
}, [settings.openAtLogin]);

// TODO do logic to switch out the connectors based on the platform
Expand Down

0 comments on commit 1e836ee

Please sign in to comment.