mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix notification rendering and disabled the auto-updater for integration tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
24f45bf45e
commit
8cbd9224ae
@ -2,7 +2,7 @@ import { autoUpdater, UpdateInfo } from "electron-updater";
|
|||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import { IpcChannel, NotificationChannelAdd, NotificationChannelPrefix } from "../common/ipc";
|
import { IpcChannel, NotificationChannelAdd, NotificationChannelPrefix } from "../common/ipc";
|
||||||
import { ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
import { isDevelopment } from "../common/vars";
|
import { isDevelopment, isTestEnv } from "../common/vars";
|
||||||
import { SemVer } from "semver";
|
import { SemVer } from "semver";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { WindowManager } from "./window-manager"
|
import { WindowManager } from "./window-manager"
|
||||||
@ -33,6 +33,7 @@ async function autoUpdateCheck(windowManager: WindowManager): Promise<void> {
|
|||||||
|
|
||||||
ipcMain
|
ipcMain
|
||||||
.on(yesNowChannel, async () => {
|
.on(yesNowChannel, async () => {
|
||||||
|
logger.info("[UPDATE CHECKER]: User chose to update immediately");
|
||||||
cleanupChannels();
|
cleanupChannels();
|
||||||
|
|
||||||
await autoUpdater.downloadUpdate();
|
await autoUpdater.downloadUpdate();
|
||||||
@ -41,6 +42,7 @@ async function autoUpdateCheck(windowManager: WindowManager): Promise<void> {
|
|||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.on(yesLaterChannel, async () => {
|
.on(yesLaterChannel, async () => {
|
||||||
|
logger.info("[UPDATE CHECKER]: User chose to update on quit");
|
||||||
cleanupChannels();
|
cleanupChannels();
|
||||||
|
|
||||||
await autoUpdater.downloadUpdate();
|
await autoUpdater.downloadUpdate();
|
||||||
@ -49,34 +51,33 @@ async function autoUpdateCheck(windowManager: WindowManager): Promise<void> {
|
|||||||
resolve();
|
resolve();
|
||||||
})
|
})
|
||||||
.on(noChannel, () => {
|
.on(noChannel, () => {
|
||||||
|
logger.info("[UPDATE CHECKER]: User chose not to update");
|
||||||
cleanupChannels();
|
cleanupChannels();
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
windowManager.mainView.webContents.send(NotificationChannelAdd, {
|
windowManager.mainView.webContents.send(NotificationChannelAdd, {
|
||||||
args: [{
|
title,
|
||||||
title,
|
body,
|
||||||
body,
|
status: "info",
|
||||||
status: "info",
|
buttons: [
|
||||||
buttons: [
|
{
|
||||||
{
|
label: "Yes, now",
|
||||||
label: "Yes, now",
|
backchannel: yesNowChannel,
|
||||||
backchannel: yesNowChannel,
|
action: true,
|
||||||
action: true,
|
},
|
||||||
},
|
{
|
||||||
{
|
label: "Yes, on quit",
|
||||||
label: "Yes, on quit",
|
backchannel: yesLaterChannel,
|
||||||
backchannel: yesLaterChannel,
|
action: true,
|
||||||
action: true,
|
},
|
||||||
},
|
{
|
||||||
{
|
label: "No",
|
||||||
label: "No",
|
backchannel: noChannel,
|
||||||
backchannel: noChannel,
|
secondary: true
|
||||||
secondary: true
|
}
|
||||||
}
|
],
|
||||||
],
|
closeChannel: noChannel,
|
||||||
closeChannel: noChannel,
|
|
||||||
}]
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -86,24 +87,24 @@ async function autoUpdateCheck(windowManager: WindowManager): Promise<void> {
|
|||||||
* @param interval milliseconds between interval to check on, defaults to 24h
|
* @param interval milliseconds between interval to check on, defaults to 24h
|
||||||
*/
|
*/
|
||||||
export function startUpdateChecking(windowManager: WindowManager, interval = 1000 * 60 * 60 * 24): void {
|
export function startUpdateChecking(windowManager: WindowManager, interval = 1000 * 60 * 60 * 24): void {
|
||||||
if (isDevelopment) {
|
if (isDevelopment || isTestEnv) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
autoUpdater.logger = logger;
|
autoUpdater.logger = logger;
|
||||||
|
autoUpdater.autoDownload = false;
|
||||||
|
autoUpdater.autoInstallOnAppQuit = false;
|
||||||
|
|
||||||
autoUpdater
|
autoUpdater
|
||||||
.on("update-available", async (args: UpdateInfo) => {
|
.on("update-available", async (args: UpdateInfo) => {
|
||||||
try {
|
try {
|
||||||
const releaseDate = moment(args.releaseDate);
|
const releaseDate = moment(args.releaseDate);
|
||||||
const body = `Version ${args.version} was release on ${releaseDate.format("dddd, mmmm dS, yyyy")}.`;
|
const body = `Version ${args.version} was release on ${releaseDate.format("dddd, MMMM Do, yyyy")}.`;
|
||||||
windowManager.mainView.webContents.send(NotificationChannelAdd, {
|
windowManager.mainView.webContents.send(NotificationChannelAdd, {
|
||||||
args: [{
|
title,
|
||||||
title,
|
body,
|
||||||
body,
|
status: "info",
|
||||||
status: "info",
|
timeout: 5000,
|
||||||
timeout: 5000,
|
|
||||||
}]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await autoUpdateCheck(windowManager);
|
await autoUpdateCheck(windowManager);
|
||||||
@ -117,12 +118,10 @@ export function startUpdateChecking(windowManager: WindowManager, interval = 100
|
|||||||
const stream = version.prerelease === null ? "stable" : "prerelease";
|
const stream = version.prerelease === null ? "stable" : "prerelease";
|
||||||
const body = `Lens is running the latest ${stream} version.`;
|
const body = `Lens is running the latest ${stream} version.`;
|
||||||
windowManager.mainView.webContents.send(NotificationChannelAdd, {
|
windowManager.mainView.webContents.send(NotificationChannelAdd, {
|
||||||
args: [{
|
title,
|
||||||
title,
|
body,
|
||||||
body,
|
status: "info",
|
||||||
status: "info",
|
timeout: 5000,
|
||||||
timeout: 5000,
|
|
||||||
}]
|
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("[UPDATE CHECKER]: notification failed", { error: String(error) })
|
logger.error("[UPDATE CHECKER]: notification failed", { error: String(error) })
|
||||||
|
|||||||
@ -25,10 +25,8 @@
|
|||||||
margin-bottom: $margin * 2;
|
margin-bottom: $margin * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
> .button {
|
.ButtonPannel button:not(:last-of-type) {
|
||||||
&:not(:last-of-type) {
|
|
||||||
margin-right: $margin;
|
margin-right: $margin;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
> .message {
|
> .message {
|
||||||
|
|||||||
@ -45,7 +45,7 @@ function RenderButtons({ id, buttons }: { id: IpcChannel, buttons?: MainNotifica
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<br />
|
<br />
|
||||||
<div className="flex row align-right box grow">
|
<div className="ButtonPannel flex row align-right box grow">
|
||||||
{buttons.map(({ backchannel, ...props}) => (
|
{buttons.map(({ backchannel, ...props}) => (
|
||||||
<Button {...props} onClick={() => {
|
<Button {...props} onClick={() => {
|
||||||
ipcRenderer.send(backchannel);
|
ipcRenderer.send(backchannel);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user