From 6b5f310f4b88da06ac6f33daa46e6179859af2e5 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Wed, 14 Sep 2022 14:19:43 -0400 Subject: [PATCH] Make releaseChannelInjectable consistent in name and ID Signed-off-by: Sebastian Malton --- .../default-update-channel.injectable.ts | 9 ++------ src/common/vars/release-channel.injectable.ts | 8 +++---- .../update-can-be-downgraded.injectable.ts | 21 ++++++------------- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/common/application-update/selected-update-channel/default-update-channel.injectable.ts b/src/common/application-update/selected-update-channel/default-update-channel.injectable.ts index 57561f03b3..44d7ff364e 100644 --- a/src/common/application-update/selected-update-channel/default-update-channel.injectable.ts +++ b/src/common/application-update/selected-update-channel/default-update-channel.injectable.ts @@ -3,17 +3,12 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { getInjectable } from "@ogre-tools/injectable"; -import currentReleaseIdInjectable from "../../vars/release-channel.injectable"; +import releaseChannelInjectable from "../../vars/release-channel.injectable"; import { updateChannels } from "../update-channels"; const defaultUpdateChannelInjectable = getInjectable({ id: "default-update-channel", - - instantiate: (di) => { - const currentReleaseId = di.inject(currentReleaseIdInjectable); - - return updateChannels[currentReleaseId ?? "latest"]; - }, + instantiate: (di) => updateChannels[di.inject(releaseChannelInjectable)], }); export default defaultUpdateChannelInjectable; diff --git a/src/common/vars/release-channel.injectable.ts b/src/common/vars/release-channel.injectable.ts index 00949e2a2c..78cc79cdb4 100644 --- a/src/common/vars/release-channel.injectable.ts +++ b/src/common/vars/release-channel.injectable.ts @@ -6,9 +6,9 @@ import { getInjectable } from "@ogre-tools/injectable"; import type { UpdateChannelId } from "../application-update/update-channels"; import appSemanticVersionInjectable from "./app-semantic-version.injectable"; -const currentReleaseIdInjectable = getInjectable({ +const releaseChannelInjectable = getInjectable({ id: "release-channel", - instantiate: (di): UpdateChannelId | undefined => { + instantiate: (di): UpdateChannelId => { const appSemanticVersion = di.inject(appSemanticVersionInjectable); const currentReleaseChannel = appSemanticVersion.prerelease[0]; @@ -18,9 +18,9 @@ const currentReleaseIdInjectable = getInjectable({ case "alpha": return currentReleaseChannel; default: - return undefined; + return "latest"; } }, }); -export default currentReleaseIdInjectable; +export default releaseChannelInjectable; diff --git a/src/main/application-update/check-for-updates/update-can-be-downgraded.injectable.ts b/src/main/application-update/check-for-updates/update-can-be-downgraded.injectable.ts index ff4179b2d2..aa8fb1b131 100644 --- a/src/main/application-update/check-for-updates/update-can-be-downgraded.injectable.ts +++ b/src/main/application-update/check-for-updates/update-can-be-downgraded.injectable.ts @@ -5,28 +5,19 @@ import { getInjectable } from "@ogre-tools/injectable"; import { computed } from "mobx"; import selectedUpdateChannelInjectable from "../../../common/application-update/selected-update-channel/selected-update-channel.injectable"; -import currentReleaseIdInjectable from "../../../common/vars/release-channel.injectable"; +import releaseChannelInjectable from "../../../common/vars/release-channel.injectable"; const updateCanBeDowngradedInjectable = getInjectable({ id: "update-can-be-downgraded", instantiate: (di) => { const selectedUpdateChannel = di.inject(selectedUpdateChannelInjectable); - const releaseChannel = di.inject(currentReleaseIdInjectable); + const releaseChannel = di.inject(releaseChannelInjectable); - return computed(() => { - if (!releaseChannel) { - return false; - } - - const currentSelectedChannel = selectedUpdateChannel.value.get().id; - - if (currentSelectedChannel !== "latest") { - return false; - } - - return releaseChannel !== "latest"; - }); + return computed(() => ( + selectedUpdateChannel.value.get().id === "latest" + && releaseChannel !== "latest" + )); }, });