From 96eb84e42529e38ea24e17f0c3ae26d0fdc5b463 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Tue, 22 Dec 2020 09:53:45 -0500 Subject: [PATCH] Respond to review comments - Remove options, always confirm, never auto prelease - Changed "yes later" to "yes on quit" - move register IpcHandlers Signed-off-by: Sebastian Malton --- src/common/user-store.ts | 4 --- src/main/app-updater.ts | 28 ++++--------------- src/main/index.ts | 3 +- src/main/window-manager.ts | 4 --- src/renderer/bootstrap.tsx | 4 --- .../components/+preferences/preferences.tsx | 18 ------------ src/renderer/lens-app.tsx | 3 ++ 7 files changed, 9 insertions(+), 55 deletions(-) diff --git a/src/common/user-store.ts b/src/common/user-store.ts index 28d249d5c8..bbd994d75a 100644 --- a/src/common/user-store.ts +++ b/src/common/user-store.ts @@ -27,8 +27,6 @@ export interface UserPreferences { downloadKubectlBinaries?: boolean; downloadBinariesPath?: string; kubectlBinariesPath?: string; - allowAutoUpdates?: boolean; - allowPrereleaseVersions?: boolean; } export class UserStore extends BaseStore { @@ -61,8 +59,6 @@ export class UserStore extends BaseStore { colorTheme: UserStore.defaultTheme, downloadMirror: "default", downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version - allowAutoUpdates: false, - allowPrereleaseVersions: false, }; get isNewVersion() { diff --git a/src/main/app-updater.ts b/src/main/app-updater.ts index 2f009904f4..d300e1bed6 100644 --- a/src/main/app-updater.ts +++ b/src/main/app-updater.ts @@ -1,6 +1,4 @@ import { autoUpdater, UpdateInfo } from "electron-updater"; -import { autorun } from "mobx"; -import { userStore } from "../common/user-store"; import logger from "./logger"; import dateFormat from "dateformat"; import { broadcastIpc, IpcChannel, NotificationChannelAdd, NotificationChannelPrefix } from "../common/ipc"; @@ -91,7 +89,7 @@ async function autoUpdateCheck(args: UpdateInfo): Promise { } }, { - label: "Yes, later", + label: "Yes, on quit", backchannel: yesLaterChannel, style: { background: "green", @@ -120,16 +118,6 @@ export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void { } autoUpdater.logger = logger; - autoUpdater.autoInstallOnAppQuit = false; - - /** - * GC saftey: This function's lifetime is the lifetime of the application. - * So no need to call the disposer. - */ - autorun(() => { - autoUpdater.autoDownload = userStore.preferences.allowAutoUpdates; - autoUpdater.allowPrerelease = userStore.preferences.allowPrereleaseVersions; - }); autoUpdater .on("update-available", async (args: UpdateInfo) => { @@ -146,21 +134,15 @@ export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void { }] }); - const version = new SemVer(args.version); - - if (userStore.preferences.allowAutoUpdates && version.prerelease !== null) { - // don't auto update to pre-release versions. - await autoUpdateNow(); - } else { - await autoUpdateCheck(args); - } + await autoUpdateCheck(args); } catch (error) { logger.error("[UPDATE CHECKER]: notification failed", { error: String(error) }) } }) - .on("update-not-available", () => { + .on("update-not-available", (args: UpdateInfo) => { try { - const stream = userStore.preferences.allowPrereleaseVersions ? "prerelease" : "stable"; + const version = new SemVer(args.version); + const stream = version.prerelease !== null ? "prerelease" : "stable"; const body = `Lens is running the latest ${stream} version.`; broadcastIpc({ channel: NotificationChannelAdd, diff --git a/src/main/index.ts b/src/main/index.ts index 4a1d488d89..44e232adc3 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -76,8 +76,7 @@ async function main() { /** * This depends on: - * 1. userStore: it reads the user's auto update settings - * 2. windowManager: it will send IPC to the main window for notifications + * 1. windowManager: it will send IPC to the main window for notifications */ startUpdateChecking(); } diff --git a/src/main/window-manager.ts b/src/main/window-manager.ts index c3ee6f9090..74aeb010ea 100644 --- a/src/main/window-manager.ts +++ b/src/main/window-manager.ts @@ -73,10 +73,6 @@ export class WindowManager { } } - send(channel: string, ...data: any[]) { - this.mainView.webContents.send(channel, ...data); - } - async showMain() { try { await this.showSplash(); diff --git a/src/renderer/bootstrap.tsx b/src/renderer/bootstrap.tsx index 6549616d9d..608a0b4005 100644 --- a/src/renderer/bootstrap.tsx +++ b/src/renderer/bootstrap.tsx @@ -31,10 +31,6 @@ export async function bootstrap(App: AppComponent) { // Register additional store listeners clusterStore.registerIpcListener(); - if (process.isMainFrame) { - notificationsStore.registerIpcListener(); - } - // init app's dependencies if any if (App.init) { await App.init(); diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index bf9ca17a43..a1b86c19cd 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -194,24 +194,6 @@ export class Preferences extends React.Component { Telemetry & usage data is collected to continuously improve the Lens experience. - -

Updates

- Allow auto updates} - value={preferences.allowAutoUpdates} - onChange={v => preferences.allowAutoUpdates = v} - /> - - Allow Lens to auto update itself to the latest version. Lens checks on startup and then once a day. - - Allow pre-release versions of Lens} - value={preferences.allowPrereleaseVersions} - onChange={v => preferences.allowPrereleaseVersions = v} - /> - - Allow upgrading Lens to pre-release versions. This means that the update checker will ask about pre release versions but won't auto upgrade to them. - ); diff --git a/src/renderer/lens-app.tsx b/src/renderer/lens-app.tsx index 70b992a910..4ad795fc2a 100644 --- a/src/renderer/lens-app.tsx +++ b/src/renderer/lens-app.tsx @@ -12,6 +12,7 @@ import { ErrorBoundary } from "./components/error-boundary"; import { WhatsNew, whatsNewRoute } from "./components/+whats-new"; import { Notifications } from "./components/notifications"; import { ConfirmDialog } from "./components/confirm-dialog"; +import { notificationsStore } from "./components/notifications/notifications.store"; @observer export class LensApp extends React.Component { @@ -22,6 +23,8 @@ export class LensApp extends React.Component { window.addEventListener("online", () => { ipcRenderer.send("network:online") }) + + notificationsStore.registerIpcListener(); } render() {