Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: call reloadLLMServicesSubscribers when app launch #702

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Easydict/Swift/Utility/GlobalContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,26 @@ import Sparkle
class GlobalContext: NSObject {
// MARK: Lifecycle

override init() {
private override init() {
self.updaterHelper = SPUUpdaterHelper()
self.userDriverHelper = SPUUserDriverHelper()
self.updaterController = SPUStandardUpdaterController(
startingUpdater: true,
updaterDelegate: updaterHelper,
userDriverDelegate: userDriverHelper
)

super.init()

reloadLLMServicesSubscribers()
}

// MARK: Internal

class SPUUpdaterHelper: NSObject, SPUUpdaterDelegate {
func feedURLString(for _: SPUUpdater) -> String? {
var feedURLString = "https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml"
var feedURLString =
"https://raw.githubusercontent.com/tisfeng/Easydict/main/appcast.xml"
#if DEBUG
feedURLString = "http://localhost:8000/appcast.xml"
#endif
Expand All @@ -47,6 +52,8 @@ class GlobalContext: NSObject {

// refresh subscribed services after duplicate service
func reloadLLMServicesSubscribers() {
logInfo("reloadLLMServicesSubscribers")

for service in services {
if let llmService = service as? LLMStreamService {
llmService.cancelSubscribers()
Expand Down
3 changes: 0 additions & 3 deletions Easydict/Swift/View/SettingView/Tabs/TabView/ServiceTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ struct ServiceTab: View {
}
.layoutPriority(1)
}
.onAppear {
GlobalContext.shared.reloadLLMServicesSubscribers()
}
.environmentObject(viewModel)
}

Expand Down