Skip to content

Commit

Permalink
fix: auto-updater not working in AppImage
Browse files Browse the repository at this point in the history
Fixes #753
  • Loading branch information
elyukai committed Feb 3, 2022
1 parent 1ed0c64 commit a24ff80
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 24 deletions.
5 changes: 3 additions & 2 deletions src/App/Containers/SettingsContainer.ts
@@ -1,3 +1,4 @@
import { ipcRenderer } from "electron"
import { connect } from "react-redux"
import { fromJust, isJust, Maybe } from "../../Data/Maybe"
import { ReduxDispatch } from "../Actions/Actions"
Expand All @@ -10,7 +11,7 @@ import { Locale, Theme } from "../Models/Config"
import { getUserSelectableSupportedLanguages } from "../Selectors/localeSelectors"
import { getFallbackLocaleId, getFallbackLocaleType, getLocaleId, getLocaleType } from "../Selectors/stateSelectors"
import { areAnimationsEnabled, getIsEditingHeroAfterCreationPhaseEnabled, getTheme } from "../Selectors/uisettingsSelectors"
import { isUpdaterEnabled } from "../Utilities/CheckForUpdatesRenderer"
import { IPCChannels } from "../Utilities/IPCChannels"
import { Settings, SettingsDispatchProps, SettingsOwnProps, SettingsStateProps } from "../Views/Settings/Settings"

const mapStateToProps = (state: AppStateRecord): SettingsStateProps => ({
Expand All @@ -22,7 +23,7 @@ const mapStateToProps = (state: AppStateRecord): SettingsStateProps => ({
areAnimationsEnabled: areAnimationsEnabled (state),
theme: getTheme (state),
languages: getUserSelectableSupportedLanguages (state),
isCheckForUpdatesDisabled: !isUpdaterEnabled (),
isCheckForUpdatesDisabled: !(ipcRenderer.sendSync (IPCChannels.IsUpdaterEnabled) as boolean),
})

const mapDispatchToProps = (dispatch: ReduxDispatch): SettingsDispatchProps => ({
Expand Down
12 changes: 0 additions & 12 deletions src/App/Utilities/CheckForUpdates.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/App/Utilities/CheckForUpdatesMain.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/App/Utilities/CheckForUpdatesRenderer.ts

This file was deleted.

3 changes: 3 additions & 0 deletions src/App/Utilities/IPCChannels.ts
@@ -0,0 +1,3 @@
export enum IPCChannels {
IsUpdaterEnabled = "isUpdaterEnabled"
}
18 changes: 16 additions & 2 deletions src/main.ts
Expand Up @@ -4,16 +4,30 @@ import * as log from "electron-log"
import { autoUpdater, CancellationToken, UpdateInfo } from "electron-updater"
import windowStateKeeper from "electron-window-state"
import { promises } from "fs"
import { platform } from "os"
import * as path from "path"
import { prerelease } from "semver"
import * as url from "url"
import { isUpdaterEnabled } from "./App/Utilities/CheckForUpdatesMain"
import { IPCChannels } from "./App/Utilities/IPCChannels"
import { existsFile } from "./System/IO"

remote.initialize ()

app.setAppUserModelId ("lukasobermann.optolith")

const isUpdaterEnabled = (() => {
switch (platform ()) {
case "darwin":
return false
default:
return autoUpdater.isUpdaterActive ()
}
}) ()

ipcMain.on (IPCChannels.IsUpdaterEnabled, event => {
event.returnValue = isUpdaterEnabled
})

const setDerivedUserDataPath = async () => {
const isPrerelease = prerelease (app.getVersion ()) !== null

Expand Down Expand Up @@ -90,7 +104,7 @@ const createWindow = async () => {
ipcMain.addListener ("loading-done", () => {
let cancellationToken: CancellationToken | undefined = undefined

if (isUpdaterEnabled ()) {
if (isUpdaterEnabled) {
console.log ("main: Updater is enabled, check for updates ...")

autoUpdater
Expand Down

0 comments on commit a24ff80

Please sign in to comment.