1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/main/update-app/selected-update-channel.injectable.ts
Janne Savolainen 1def5d1354
Allow downgrading app versions
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-05-20 14:10:53 +03:00

33 lines
988 B
TypeScript

/**
* 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 type { IComputedValue } from "mobx";
import { action, computed, observable } from "mobx";
import type { UpdateChannel, UpdateChannelId } from "./update-channels";
import { updateChannels } from "./update-channels";
export interface SelectedUpdateChannel {
value: IComputedValue<UpdateChannel>;
setValue: (channelId: UpdateChannelId) => void;
}
const selectedUpdateChannelInjectable = getInjectable({
id: "selected-update-channel",
instantiate: (): SelectedUpdateChannel => {
const state = observable.box(updateChannels.latest);
return {
value: computed(() => state.get()),
setValue: action((channelId: UpdateChannelId) => {
state.set(updateChannels[channelId]);
}),
};
},
});
export default selectedUpdateChannelInjectable;