-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Refactor] Introduce
GlobalContext
and migrate the updater controll…
…er into it (#365) * introduce global context and migrate updater controller into * refactor: mutually initialize global context * revert `@Default` in `EasydictApp` * fix: remove updaterController from Main.storyboard * style: fix typo * fix: updaterDelegate was nil * perf: set updaterHelper to private * perf: remove sparkle code from AppDelegate * perf: remove unused #import header --------- Co-authored-by: Tisfeng <[email protected]>
- Loading branch information
1 parent
b6974d1
commit 5d30f34
Showing
11 changed files
with
83 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// GlobalContext.swift | ||
// Easydict | ||
// | ||
// Created by 戴藏龙 on 2024/1/25. | ||
// Copyright © 2024 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Sparkle | ||
|
||
@objcMembers | ||
class GlobalContext: NSObject { | ||
static let shared = GlobalContext() | ||
|
||
let updaterController: SPUStandardUpdaterController | ||
|
||
private let updaterHelper: SPUUpdaterHelper | ||
private let userDriverHelper: SPUUserDriverHelper | ||
|
||
override init() { | ||
updaterHelper = SPUUpdaterHelper() | ||
userDriverHelper = SPUUserDriverHelper() | ||
|
||
updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: updaterHelper, userDriverDelegate: userDriverHelper) | ||
} | ||
|
||
class SPUUpdaterHelper: NSObject, SPUUpdaterDelegate { | ||
func feedURLString(for _: SPUUpdater) -> String? { | ||
var feedURLString = "https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml" | ||
#if DEBUG | ||
feedURLString = "http://localhost:8000/appcast.xml" | ||
#endif | ||
return feedURLString | ||
} | ||
} | ||
|
||
class SPUUserDriverHelper: NSObject, SPUStandardUserDriverDelegate { | ||
var supportsGentleScheduledUpdateReminders: Bool { | ||
true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters