mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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 <sebastian@malton.name>
This commit is contained in:
parent
cd154a8343
commit
96eb84e425
@ -27,8 +27,6 @@ export interface UserPreferences {
|
||||
downloadKubectlBinaries?: boolean;
|
||||
downloadBinariesPath?: string;
|
||||
kubectlBinariesPath?: string;
|
||||
allowAutoUpdates?: boolean;
|
||||
allowPrereleaseVersions?: boolean;
|
||||
}
|
||||
|
||||
export class UserStore extends BaseStore<UserStoreModel> {
|
||||
@ -61,8 +59,6 @@ export class UserStore extends BaseStore<UserStoreModel> {
|
||||
colorTheme: UserStore.defaultTheme,
|
||||
downloadMirror: "default",
|
||||
downloadKubectlBinaries: true, // Download kubectl binaries matching cluster version
|
||||
allowAutoUpdates: false,
|
||||
allowPrereleaseVersions: false,
|
||||
};
|
||||
|
||||
get isNewVersion() {
|
||||
|
||||
@ -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<void> {
|
||||
}
|
||||
},
|
||||
{
|
||||
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,
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -73,10 +73,6 @@ export class WindowManager {
|
||||
}
|
||||
}
|
||||
|
||||
send(channel: string, ...data: any[]) {
|
||||
this.mainView.webContents.send(channel, ...data);
|
||||
}
|
||||
|
||||
async showMain() {
|
||||
try {
|
||||
await this.showSplash();
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -194,24 +194,6 @@ export class Preferences extends React.Component {
|
||||
<small className="hint">
|
||||
<Trans>Telemetry & usage data is collected to continuously improve the Lens experience.</Trans>
|
||||
</small>
|
||||
|
||||
<h2><Trans>Updates</Trans></h2>
|
||||
<Checkbox
|
||||
label={<Trans>Allow auto updates</Trans>}
|
||||
value={preferences.allowAutoUpdates}
|
||||
onChange={v => preferences.allowAutoUpdates = v}
|
||||
/>
|
||||
<small className="hint">
|
||||
<Trans>Allow Lens to auto update itself to the latest version. Lens checks on startup and then once a day.</Trans>
|
||||
</small>
|
||||
<Checkbox
|
||||
label={<Trans>Allow pre-release versions of Lens</Trans>}
|
||||
value={preferences.allowPrereleaseVersions}
|
||||
onChange={v => preferences.allowPrereleaseVersions = v}
|
||||
/>
|
||||
<small className="hint">
|
||||
<Trans>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.</Trans>
|
||||
</small>
|
||||
</WizardLayout>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -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() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user