Skip to content

Commit

Permalink
fix: Updates would not be displayed without restarting the app (#136)
Browse files Browse the repository at this point in the history
Two `BookmarksManager` instances were being initialized at app startup; one was being used for display, and the other was processing the updates, meaning that the UI was never notified of the updates.
  • Loading branch information
jbmorley authored Jul 17, 2021
1 parent 5754748 commit 24ad758
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
3 changes: 1 addition & 2 deletions core/BookmarksCore/Common/BookmarksManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ public class BookmarksManager {
thumbnailManager = ThumbnailManager(imageCache: imageCache, downloadManager: downloadManager)
updater = Updater(store: store, token: settings.pinboardApiKey)

#if targetEnvironment(macCatalyst)
#if os(macOS)
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self, selector: #selector(nsApplicationDidBecomeActive),
name: NSNotification.Name("NSApplicationDidBecomeActiveNotification"),
object: nil)
#endif

}

@objc
Expand Down
12 changes: 0 additions & 12 deletions macos/Bookmarks/BookmarksApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,17 @@ import SwiftUI

import BookmarksCore

class AppDelegate: NSObject, NSApplicationDelegate {

var manager = BookmarksManager()

func applicationDidBecomeActive(_ notification: Notification) {
manager.updater.start()
}
}

@main
struct BookmarksApp: App {

@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
@Environment(\.manager) var manager: BookmarksManager

var body: some Scene {
WindowGroup {
ContentView(store: manager.store)
.environment(\.manager, appDelegate.manager)
}
SwiftUI.Settings {
SettingsView()
.environment(\.manager, appDelegate.manager)
}
}
}

0 comments on commit 24ad758

Please sign in to comment.