1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Make releaseChannelInjectable consistent in name and ID

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-09-14 14:19:43 -04:00
parent a52d95a165
commit 6b5f310f4b
3 changed files with 12 additions and 26 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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"
));
},
});