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 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({
|
||||
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 updateCanBeDowngradedInjectable from "./update-can-be-downgraded.injectable";
|
||||
|
||||
interface CheckForUpdatesFromChannelResult {
|
||||
updateWasDiscovered: boolean;
|
||||
version?: string;
|
||||
actualUpdateChannel?: UpdateChannel;
|
||||
}
|
||||
export type CheckForUpdatesFromChannelResult = {
|
||||
updateWasDiscovered: false;
|
||||
} | {
|
||||
updateWasDiscovered: true;
|
||||
version: string;
|
||||
actualUpdateChannel: UpdateChannel;
|
||||
};
|
||||
|
||||
const checkForUpdatesStartingFromChannelInjectable = getInjectable({
|
||||
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 discoveredUpdateVersionInjectable from "../../../common/application-update/discovered-update-version/discovered-update-version.injectable";
|
||||
import { runInAction } from "mobx";
|
||||
import assert from "assert";
|
||||
import askBooleanInjectable from "../../ask-boolean/ask-boolean.injectable";
|
||||
import quitAndInstallUpdateInjectable from "../../electron-app/features/quit-and-install-update.injectable";
|
||||
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
||||
@ -36,10 +35,9 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
||||
checkingForUpdatesState.set(true);
|
||||
});
|
||||
|
||||
const { updateWasDiscovered, version, actualUpdateChannel } =
|
||||
await checkForUpdatesStartingFromChannel(selectedUpdateChannel.value.get());
|
||||
const result = await checkForUpdatesStartingFromChannel(selectedUpdateChannel.value.get());
|
||||
|
||||
if (!updateWasDiscovered) {
|
||||
if (!result.updateWasDiscovered) {
|
||||
broadcastChangeInUpdatingStatus({ eventId: "no-updates-available" });
|
||||
|
||||
runInAction(() => {
|
||||
@ -50,16 +48,14 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
||||
return;
|
||||
}
|
||||
|
||||
const { version, actualUpdateChannel } = result;
|
||||
|
||||
broadcastChangeInUpdatingStatus({
|
||||
eventId: "download-for-update-started",
|
||||
version,
|
||||
});
|
||||
|
||||
runInAction(() => {
|
||||
// TODO: Unacceptable damage caused by strict mode
|
||||
assert(version);
|
||||
assert(actualUpdateChannel);
|
||||
|
||||
discoveredVersionState.set({
|
||||
version,
|
||||
updateChannel: actualUpdateChannel,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user