Extract tray icon path as injectable

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne SavolainenandMikko Aspiala committed 2022-05-11 08:25:35 +03:00
1 parent 76e6718874
commit 0d41eabb64
2 files changed
+29

No files matched your search

@@ -0,0 +1,26 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import getAbsolutePathInjectable from "../../common/path/get-absolute-path.injectable";
import isDevelopmentInjectable from "../../common/vars/is-development.injectable";
import staticFilesDirectoryInjectable from "../../common/vars/static-files-directory.injectable";
const trayIconPathInjectable = getInjectable({
id: "tray-icon-path",
instantiate: (di) => {
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const isDevelopment = di.inject(isDevelopmentInjectable);
const staticDir = di.inject(staticFilesDirectoryInjectable);
return getAbsolutePath(
staticDir,
isDevelopment ? "../build/tray" : "icons", // copied within electron-builder extras
"trayIconTemplate.png",
);
},
});
export default trayIconPathInjectable;
+3
View File
@@ -10,6 +10,7 @@ import navigateToPreferencesInjectable from "../../common/front-end-routing/rout
import stopServicesAndExitAppInjectable from "../stop-services-and-exit-app.injectable";
import { getStartableStoppable } from "../../common/utils/get-startable-stoppable";
import isAutoUpdateEnabledInjectable from "../is-auto-update-enabled.injectable";
import trayIconPathInjectable from "./tray-icon-path.injectable";
const trayInjectable = getInjectable({
id: "tray",
@@ -20,6 +21,7 @@ const trayInjectable = getInjectable({
const navigateToPreferences = di.inject(navigateToPreferencesInjectable);
const stopServicesAndExitApp = di.inject(stopServicesAndExitAppInjectable);
const isAutoUpdateEnabled = di.inject(isAutoUpdateEnabledInjectable);
const trayIconPath = di.inject(trayIconPathInjectable);
return getStartableStoppable("build-of-tray", () =>
initTray(
@@ -28,6 +30,7 @@ const trayInjectable = getInjectable({
navigateToPreferences,
stopServicesAndExitApp,
isAutoUpdateEnabled,
trayIconPath,
),
);
},