mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix CheckForUpdate type errors
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
02023e9c18
commit
62ea050f94
@ -8,7 +8,14 @@ import type { UpdateChannel } from "../../../common/application-update/update-ch
|
|||||||
import loggerInjectable from "../../../common/logger.injectable";
|
import loggerInjectable from "../../../common/logger.injectable";
|
||||||
import type { UpdateCheckResult } from "electron-updater";
|
import type { UpdateCheckResult } from "electron-updater";
|
||||||
|
|
||||||
export type CheckForPlatformUpdates = (updateChannel: UpdateChannel, opts: { allowDowngrade: boolean }) => Promise<{ updateWasDiscovered: boolean; version?: string }>;
|
export type CheckForUpdatesResult = {
|
||||||
|
updateWasDiscovered: false;
|
||||||
|
} | {
|
||||||
|
updateWasDiscovered: true;
|
||||||
|
version: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CheckForPlatformUpdates = (updateChannel: UpdateChannel, opts: { allowDowngrade: boolean }) => Promise<CheckForUpdatesResult>;
|
||||||
|
|
||||||
const checkForPlatformUpdatesInjectable = getInjectable({
|
const checkForPlatformUpdatesInjectable = getInjectable({
|
||||||
id: "check-for-platform-updates",
|
id: "check-for-platform-updates",
|
||||||
|
|||||||
@ -7,11 +7,13 @@ import type { UpdateChannel } from "../../../common/application-update/update-ch
|
|||||||
import checkForPlatformUpdatesInjectable from "../check-for-platform-updates/check-for-platform-updates.injectable";
|
import checkForPlatformUpdatesInjectable from "../check-for-platform-updates/check-for-platform-updates.injectable";
|
||||||
import updateCanBeDowngradedInjectable from "./update-can-be-downgraded.injectable";
|
import updateCanBeDowngradedInjectable from "./update-can-be-downgraded.injectable";
|
||||||
|
|
||||||
interface CheckForUpdatesFromChannelResult {
|
export type CheckForUpdatesFromChannelResult = {
|
||||||
updateWasDiscovered: boolean;
|
updateWasDiscovered: false;
|
||||||
version?: string;
|
} | {
|
||||||
actualUpdateChannel?: UpdateChannel;
|
updateWasDiscovered: true;
|
||||||
}
|
version: string;
|
||||||
|
actualUpdateChannel: UpdateChannel;
|
||||||
|
};
|
||||||
|
|
||||||
const checkForUpdatesStartingFromChannelInjectable = getInjectable({
|
const checkForUpdatesStartingFromChannelInjectable = getInjectable({
|
||||||
id: "check-for-updates-starting-from-channel",
|
id: "check-for-updates-starting-from-channel",
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import selectedUpdateChannelInjectable from "../../../common/application-update/
|
|||||||
import updatesAreBeingDiscoveredInjectable from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
import updatesAreBeingDiscoveredInjectable from "../../../common/application-update/updates-are-being-discovered/updates-are-being-discovered.injectable";
|
||||||
import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
import discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
||||||
import { runInAction } from "mobx";
|
import { runInAction } from "mobx";
|
||||||
import assert from "assert";
|
|
||||||
import askBooleanInjectable from "../../ask-boolean/ask-boolean.injectable";
|
import askBooleanInjectable from "../../ask-boolean/ask-boolean.injectable";
|
||||||
import quitAndInstallUpdateInjectable from "../../electron-app/features/quit-and-install-update.injectable";
|
import quitAndInstallUpdateInjectable from "../../electron-app/features/quit-and-install-update.injectable";
|
||||||
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
||||||
@ -36,10 +35,9 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
|||||||
checkingForUpdatesState.set(true);
|
checkingForUpdatesState.set(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
const { updateWasDiscovered, version, actualUpdateChannel } =
|
const result = await checkForUpdatesStartingFromChannel(selectedUpdateChannel.value.get());
|
||||||
await checkForUpdatesStartingFromChannel(selectedUpdateChannel.value.get());
|
|
||||||
|
|
||||||
if (!updateWasDiscovered) {
|
if (!result.updateWasDiscovered) {
|
||||||
broadcastChangeInUpdatingStatus({ eventId: "no-updates-available" });
|
broadcastChangeInUpdatingStatus({ eventId: "no-updates-available" });
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
@ -50,16 +48,14 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { version, actualUpdateChannel } = result;
|
||||||
|
|
||||||
broadcastChangeInUpdatingStatus({
|
broadcastChangeInUpdatingStatus({
|
||||||
eventId: "download-for-update-started",
|
eventId: "download-for-update-started",
|
||||||
version,
|
version,
|
||||||
});
|
});
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
// TODO: Unacceptable damage caused by strict mode
|
|
||||||
assert(version);
|
|
||||||
assert(actualUpdateChannel);
|
|
||||||
|
|
||||||
discoveredVersionState.set({
|
discoveredVersionState.set({
|
||||||
version,
|
version,
|
||||||
updateChannel: actualUpdateChannel,
|
updateChannel: actualUpdateChannel,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user