Skip to content

Commit

Permalink
Add general.checksForUpdates to settings.json (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanzhong authored Jan 5, 2025
1 parent 4282733 commit 7f605e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions MarkEditMac/Sources/Main/AppRuntimeConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ enum AppRuntimeConfig {
let indentBehavior: EditorIndentBehavior?
let writingToolsBehavior: String?
let headerFontSizeDiffs: [Double]?
let checksForUpdates: Bool?
let defaultOpenDirectory: String?
let defaultSaveDirectory: String?
let disableCorsRestrictions: Bool?
Expand All @@ -39,6 +40,7 @@ enum AppRuntimeConfig {
case indentBehavior = "editor.indentBehavior"
case writingToolsBehavior = "editor.writingToolsBehavior"
case headerFontSizeDiffs = "editor.headerFontSizeDiffs"
case checksForUpdates = "general.checksForUpdates"
case defaultOpenDirectory = "general.defaultOpenDirectory"
case defaultSaveDirectory = "general.defaultSaveDirectory"
case disableCorsRestrictions = "general.disableCorsRestrictions"
Expand Down Expand Up @@ -78,6 +80,11 @@ enum AppRuntimeConfig {
currentDefinition?.headerFontSizeDiffs
}

static var checksForUpdates: Bool {
// Enable automatic updates by default
currentDefinition?.checksForUpdates ?? true
}

static var defaultOpenDirectory: String? {
// Unspecified by default
currentDefinition?.defaultOpenDirectory
Expand Down Expand Up @@ -112,6 +119,7 @@ private extension AppRuntimeConfig {
indentBehavior: .never,
writingToolsBehavior: nil, // [macOS 15] Complete mode still has lots of bugs
headerFontSizeDiffs: nil,
checksForUpdates: true,
defaultOpenDirectory: nil,
defaultSaveDirectory: nil,
disableCorsRestrictions: nil,
Expand Down
7 changes: 6 additions & 1 deletion MarkEditMac/Sources/Updater/AppUpdater.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum AppUpdater {
}

static func checkForUpdates(explicitly: Bool) async {
guard explicitly || !AppPreferences.Updater.completelyDisabled else {
guard explicitly || automatically else {
return Logger.log(.info, "App update checks have been skipped")
}

Expand Down Expand Up @@ -83,6 +83,11 @@ enum AppUpdater {
// MARK: - Private

private extension AppUpdater {
static var automatically: Bool {
// Can be disabled through either settings.json or an incompatible update
AppRuntimeConfig.checksForUpdates && !AppPreferences.Updater.completelyDisabled
}

static func extractReleaseInfo(from version: AppVersion) async -> ReleaseInfo? {
guard let info = (version.assets?.first { $0.name == "ReleaseInfo.json" }) else {
Logger.log(.error, "Missing ReleaseInfo.json")
Expand Down

0 comments on commit 7f605e0

Please sign in to comment.