forked from oliverschwendener/ueli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add settings to show/hide the app icon in the dock on macOS (oliversc…
…hwendener#1228) * feat: add settings to toggle "show in dock" on macOS * chore: remove unnecessary console.logs * fix: use descriptive parameter in toggleAppIconInDock * chore: bootstrap Dock module after SettingsManager instead of at the end - unecessarily far down * refactor: apply namespace for i18n directly in DockSettings * refactor: move toggleAppIconInDock function into bootstap as inlined anonymous function * chore: rename toggleAppIconInDock to setAppIconVisibility * refactor!: move Dock settings to General settings * refactor: don't prop-drill the contextBridge hook * style: add line break, remove unnecessary variable in `DockModule` * refactor: move OS check for Dock settings to `General.tsx`
- Loading branch information
1 parent
723c93b
commit 93234a8
Showing
5 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
import type { App } from "electron"; | ||
import type { Dependencies } from "@Core/Dependencies"; | ||
import type { DependencyRegistry } from "@Core/DependencyRegistry"; | ||
|
||
export class DockModule { | ||
public static bootstrap(app: App) { | ||
app.dock?.hide(); | ||
public static bootstrap(dependencyRegistry: DependencyRegistry<Dependencies>) { | ||
const app = dependencyRegistry.get("App"); | ||
const settingsManager = dependencyRegistry.get("SettingsManager"); | ||
const eventSubscriber = dependencyRegistry.get("EventSubscriber"); | ||
|
||
const setAppIconVisibility = () => { | ||
if (settingsManager.getValue("appearance.showAppIconInDock", false)) { | ||
app.dock?.show(); | ||
} else { | ||
app.dock?.hide(); | ||
} | ||
}; | ||
|
||
setAppIconVisibility(); | ||
|
||
eventSubscriber.subscribe("settingUpdated[appearance.showAppIconInDock]", setAppIconVisibility); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useContextBridge, useSetting } from "@Core/Hooks"; | ||
import { Setting } from "@Core/Settings/Setting"; | ||
import { Switch } from "@fluentui/react-components"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export const DockSettings = () => { | ||
const { t } = useTranslation("settingsGeneral"); | ||
const { contextBridge } = useContextBridge(); | ||
|
||
const { value: showAppIconInDock, updateValue: setShowAppIconInDock } = useSetting<boolean>({ | ||
key: "appearance.showAppIconInDock", | ||
defaultValue: false, | ||
}); | ||
|
||
const updateShowAppIconInDock = async (value: boolean) => { | ||
await contextBridge.updateSettingValue("appearance.showAppIconInDock", value); | ||
setShowAppIconInDock(value); | ||
}; | ||
|
||
return ( | ||
<Setting | ||
label={t("showAppIconInDock")} | ||
control={ | ||
<Switch checked={showAppIconInDock} onChange={(_, { checked }) => updateShowAppIconInDock(checked)} /> | ||
} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters