Skip to content

Commit

Permalink
Fix "conflict with KVO"
Browse files Browse the repository at this point in the history
  • Loading branch information
pakerwreah committed Jul 31, 2023
1 parent 7383909 commit 97b8a36
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 25 deletions.
6 changes: 3 additions & 3 deletions Calendr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.10.0;
MARKETING_VERSION = 1.10.1;
PRODUCT_BUNDLE_IDENTIFIER = br.paker.Calendr;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Calendr/Config/Calendr-Bridging-Header.h";
Expand All @@ -1285,7 +1285,7 @@
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.10.0;
MARKETING_VERSION = 1.10.1;
PRODUCT_BUNDLE_IDENTIFIER = br.paker.Calendr;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Calendr/Config/Calendr-Bridging-Header.h";
Expand Down Expand Up @@ -1380,7 +1380,7 @@
repositoryURL = "https://github.com/ReactiveX/RxSwift";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 6.2.0;
minimumVersion = 6.6.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ReactiveX/RxSwift",
"state" : {
"revision" : "b4307ba0b6425c0ba4178e138799946c3da594f8",
"version" : "6.5.0"
"revision" : "9dcaa4b333db437b0fbfaf453fad29069044a8b4",
"version" : "6.6.0"
}
}
],
Expand Down
38 changes: 18 additions & 20 deletions Calendr/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class MainViewController: NSViewController, NSPopoverDelegate {
calendarsViewModel: calendarPickerViewModel,
notificationCenter: notificationCenter
)
/// Fix weird "conflict with KVO" issue on RxSwift if we present settings
/// view controller before calling `methodInvoked` at least once.
/// If we don't do this, the app crashes in `setUpPopover`.
settingsViewController.rx.viewDidLoad.subscribe().dispose()

let (hoverObservable, hoverObserver) = PublishSubject<Date?>.pipe()

Expand Down Expand Up @@ -486,16 +490,13 @@ class MainViewController: NSViewController, NSPopoverDelegate {
@objc func mainStatusItemAction() {
guard let event = NSApp.currentEvent else { return }

// try to avoid weird "conflict with KVO" bug from RxSwift
DispatchQueue.main.async {
switch event.type {
case .leftMouseUp:
self.mainStatusItemLeftClick.onNext(())
case .rightMouseUp:
self.mainStatusItemRightClick.onNext(())
default:
break
}
switch event.type {
case .leftMouseUp:
self.mainStatusItemLeftClick.onNext(())
case .rightMouseUp:
self.mainStatusItemRightClick.onNext(())
default:
break
}
}

Expand Down Expand Up @@ -561,16 +562,13 @@ class MainViewController: NSViewController, NSPopoverDelegate {
@objc func eventStatusItemAction() {
guard let event = NSApp.currentEvent else { return }

// try to avoid weird "conflict with KVO" bug from RxSwift
DispatchQueue.main.async {
switch event.type {
case .leftMouseUp:
self.eventStatusItemLeftClick.onNext(())
case .rightMouseUp:
self.eventStatusItemRightClick.onNext(())
default:
break
}
switch event.type {
case .leftMouseUp:
self.eventStatusItemLeftClick.onNext(())
case .rightMouseUp:
self.eventStatusItemRightClick.onNext(())
default:
break
}
}

Expand Down

0 comments on commit 97b8a36

Please sign in to comment.