fix: updater should closes all window first
Signed-off-by: Innei <i@innei.in>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
let shouldAppDoHide = process.platform === "darwin"
|
||||
|
||||
export const getShouldAppDoHide = () => shouldAppDoHide
|
||||
export const setShouldAppDoHide = (value: boolean) => {
|
||||
shouldAppDoHide = value
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { getRendererHandlers } from "@egoist/tipc/main"
|
||||
import { autoUpdater } from "electron-updater"
|
||||
|
||||
import { channel, isDev } from "../env"
|
||||
import { setShouldAppDoHide } from "../flag"
|
||||
import { trackEvent } from "../lib/posthog"
|
||||
import { logger } from "../logger"
|
||||
import type { RendererHandlers } from "../renderer-handlers"
|
||||
@@ -12,7 +13,16 @@ import { CustomGitHubProvider } from "./custom-github-provider"
|
||||
const disabled = isDev
|
||||
|
||||
export const quitAndInstall = async () => {
|
||||
autoUpdater.quitAndInstall()
|
||||
setShouldAppDoHide(false)
|
||||
const mainWindow = getMainWindow()
|
||||
|
||||
logger.info("Quit and install update, close main window, ", mainWindow?.id)
|
||||
mainWindow?.close()
|
||||
|
||||
setTimeout(() => {
|
||||
logger.info("Window is closed, quit and install update")
|
||||
autoUpdater.quitAndInstall()
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
let downloading = false
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import { callGlobalContextMethod } from "@shared/bridge"
|
||||
import type { BrowserWindowConstructorOptions } from "electron"
|
||||
import { BrowserWindow, Menu, shell } from "electron"
|
||||
|
||||
import { getShouldAppDoHide } from "./flag"
|
||||
import { getIconPath } from "./helper"
|
||||
import { store } from "./lib/store"
|
||||
import { logger } from "./logger"
|
||||
@@ -203,7 +204,7 @@ export const createMainWindow = () => {
|
||||
windows.mainWindow = window
|
||||
|
||||
window.on("close", (event) => {
|
||||
if (process.platform === "darwin") {
|
||||
if (process.platform === "darwin" && getShouldAppDoHide()) {
|
||||
event.preventDefault()
|
||||
window.hide()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user