Tweak code style

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-20 14:10:41 +03:00
1 parent 7a00541599
commit 7623dc7bad
6 files changed
+19 -13

No files matched your search

@@ -82,7 +82,7 @@ const convertToElectronMenuTemplate = (trayMenuItems: TrayMenuItem[]) => {
return { return {
id: trayMenuItem.id, id: trayMenuItem.id,
label: trayMenuItem.label.get(), label: trayMenuItem.label?.get(),
enabled: trayMenuItem.enabled.get(), enabled: trayMenuItem.enabled.get(),
toolTip: trayMenuItem.tooltip, toolTip: trayMenuItem.tooltip,
@@ -16,11 +16,13 @@ import type { TrayMenuRegistration } from "../tray-menu-registration";
const trayMenuItemRegistratorInjectable = getInjectable({ const trayMenuItemRegistratorInjectable = getInjectable({
id: "tray-menu-item-registrator", id: "tray-menu-item-registrator",
instantiate: (di) => (extension: LensMainExtension, installationCounter) => { instantiate: (di) => (extension, installationCounter) => {
pipeline( const mainExtension = extension as LensMainExtension;
extension.trayMenus,
flatMap(toItemInjectablesFor(extension, installationCounter)), pipeline(
mainExtension.trayMenus,
flatMap(toItemInjectablesFor(mainExtension, installationCounter)),
(injectables) => di.register(...injectables), (injectables) => di.register(...injectables),
); );
@@ -34,7 +36,7 @@ export default trayMenuItemRegistratorInjectable;
const toItemInjectablesFor = (extension: LensMainExtension, installationCounter: number) => { const toItemInjectablesFor = (extension: LensMainExtension, installationCounter: number) => {
const _toItemInjectables = (parentId: string | null) => (registration: TrayMenuRegistration): Injectable<TrayMenuItem, TrayMenuItem, void>[] => { const _toItemInjectables = (parentId: string | null) => (registration: TrayMenuRegistration): Injectable<TrayMenuItem, TrayMenuItem, void>[] => {
const trayItemId = registration.id || kebabCase(registration.label); const trayItemId = registration.id || kebabCase(registration.label || "");
const id = `${trayItemId}-tray-menu-item-for-extension-${extension.sanitizedExtensionId}-instance-${installationCounter}`; const id = `${trayItemId}-tray-menu-item-for-extension-${extension.sanitizedExtensionId}-instance-${installationCounter}`;
const parentInjectable = getInjectable({ const parentInjectable = getInjectable({
@@ -47,14 +49,14 @@ const toItemInjectablesFor = (extension: LensMainExtension, installationCounter:
separator: registration.type === "separator", separator: registration.type === "separator",
label: computed(() => registration.label), label: computed(() => registration.label || ""),
tooltip: registration.toolTip, tooltip: registration.toolTip,
click: () => { click: () => {
registration.click?.(registration); registration.click?.(registration);
}, },
enabled: computed(() => registration.enabled), enabled: computed(() => !!registration.enabled),
visible: computed(() => true), visible: computed(() => true),
}), }),
+1 -1
View File
@@ -72,7 +72,7 @@ const toTrayMenuOptions = (trayMenuItems: TrayMenuItem[]) => {
return { return {
id: trayMenuItem.id, id: trayMenuItem.id,
label: trayMenuItem.label.get(), label: trayMenuItem.label?.get(),
enabled: trayMenuItem.enabled.get(), enabled: trayMenuItem.enabled.get(),
toolTip: trayMenuItem.tooltip, toolTip: trayMenuItem.tooltip,
@@ -23,7 +23,7 @@ const installApplicationUpdateTrayItemInjectable = getInjectable({
orderNumber: 50, orderNumber: 50,
label: computed(() => { label: computed(() => {
const versionToBeInstalled = discoveredVersionState.value.get().version; const versionToBeInstalled = discoveredVersionState.value.get()?.version;
return `Install update ${versionToBeInstalled}`; return `Install update ${versionToBeInstalled}`;
}), }),
@@ -31,7 +31,7 @@ const installApplicationUpdateTrayItemInjectable = getInjectable({
enabled: computed(() => true), enabled: computed(() => true),
visible: computed( visible: computed(
() => discoveredVersionState.value.get() && !downloadingUpdateState.value.get(), () => !!discoveredVersionState.value.get() && !downloadingUpdateState.value.get(),
), ),
click: () => { click: () => {
@@ -27,7 +27,11 @@ const watchIfUpdateShouldHappenOnQuitInjectable = getInjectable({
const updateIsDiscoveredFromChannel = discoveredVersion?.updateChannel; const updateIsDiscoveredFromChannel = discoveredVersion?.updateChannel;
const updateOnQuit = sufficientlyStableUpdateChannels.includes(updateIsDiscoveredFromChannel); const updateOnQuit = updateIsDiscoveredFromChannel
? sufficientlyStableUpdateChannels.includes(
updateIsDiscoveredFromChannel,
)
: false;
setUpdateOnQuit(updateOnQuit); setUpdateOnQuit(updateOnQuit);
}), }),
+1 -1
View File
@@ -123,7 +123,7 @@ export const overrideIpcBridge = ({
); );
rendererDi.override(sendToMainInjectable, () => (channelId, message) => { rendererDi.override(sendToMainInjectable, () => (channelId, message) => {
const handles = mainIpcFakeHandles.get(channelId); const handles = mainIpcFakeHandles.get(channelId) || [];
if (isEmpty(handles)) { if (isEmpty(handles)) {
throw new Error( throw new Error(