From 8655c29a3730779e92e88f4ef83b225bee4d3eaa Mon Sep 17 00:00:00 2001 From: Carlos Enumo Date: Sat, 13 Apr 2024 19:02:27 +0100 Subject: [PATCH] =?UTF-8?q?Use=20implicit=20self=20after=20guard=20?= =?UTF-8?q?=F0=9F=8D=82=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Calendr/Main/MainViewController.swift | 29 +++++++++---------- .../Providers/CalendarServiceProvider.swift | 2 +- .../CalendarPickerViewController.swift | 4 +-- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Calendr/Main/MainViewController.swift b/Calendr/Main/MainViewController.swift index 1eccf0f1..97517318 100644 --- a/Calendr/Main/MainViewController.swift +++ b/Calendr/Main/MainViewController.swift @@ -512,14 +512,13 @@ class MainViewController: NSViewController, NSPopoverDelegate { let clickHandler = mainStatusItemClickHandler clickHandler.leftClick - .enumerated() - .flatMapFirst { [weak self] pass, _ -> Observable in + .flatMapFirst { [weak self] _ -> Observable in guard let self else { return .empty() } - self.forceLayout() + forceLayout() let popover = NSPopover() - self.setUpAndShow(popover, from: statusBarButton) + setUpAndShow(popover, from: statusBarButton) return popover.rx.deallocated } @@ -626,13 +625,13 @@ class MainViewController: NSViewController, NSPopoverDelegate { keyboard.handler = { [weak self] event -> NSEvent? in guard let self, - (try? self.isShowingDetails.value()) == false, + (try? isShowingDetails.value()) == false, let key = Keyboard.Key.from(event) else { return event } - if let vc = self.presentedViewControllers?.last { + if let vc = presentedViewControllers?.last { guard key ~= .escape else { return event } - self.dismiss(vc) + dismiss(vc) return .none } @@ -641,16 +640,16 @@ class MainViewController: NSViewController, NSPopoverDelegate { NSApp.terminate(nil) case .command("f"): - self.showSearchInput() + showSearchInput() case .command(","): - self.openSettings() + openSettings() - case .escape where self.searchInput.hasFocus: - self.hideSearchInput() + case .escape where searchInput.hasFocus: + hideSearchInput() - case .arrow(let arrow) where !self.searchInput.hasFocus: - self.arrowSubject.onNext(arrow) + case .arrow(let arrow) where !searchInput.hasFocus: + arrowSubject.onNext(arrow) default: return event @@ -662,11 +661,11 @@ class MainViewController: NSViewController, NSPopoverDelegate { // Global shortcut KeyboardShortcuts.onKeyUp(for: .showMainPopover) { [weak self] in guard let self else { return } - if let window = self.view.window { + if let window = view.window { window.performClose(nil) return } - self.mainStatusItemClickHandler.leftClick.onNext(()) + mainStatusItemClickHandler.leftClick.onNext(()) } } diff --git a/Calendr/Providers/CalendarServiceProvider.swift b/Calendr/Providers/CalendarServiceProvider.swift index 40efa1af..53bfd406 100644 --- a/Calendr/Providers/CalendarServiceProvider.swift +++ b/Calendr/Providers/CalendarServiceProvider.swift @@ -74,7 +74,7 @@ class CalendarServiceProvider: CalendarServiceProviding { Observable.create { [weak self] observer in if let self { - observer.onNext(self.storeCalendars().map(CalendarModel.init(from:))) + observer.onNext(storeCalendars().map(CalendarModel.init(from:))) } observer.onCompleted() diff --git a/Calendr/Settings/CalendarPickerViewController.swift b/Calendr/Settings/CalendarPickerViewController.swift index 04cd2083..f54e2b1b 100644 --- a/Calendr/Settings/CalendarPickerViewController.swift +++ b/Calendr/Settings/CalendarPickerViewController.swift @@ -80,9 +80,9 @@ class CalendarPickerViewController: NSViewController { ) .observe(on: MainScheduler.instance) .compactMap { [weak self] calendars, showNextEvent -> [NSView]? in - guard let self = self else { return nil } + guard let self else { return nil } - self.itemsDisposeBag = DisposeBag() + itemsDisposeBag = DisposeBag() return Dictionary(grouping: calendars, by: { $0.account }) .sorted(by: \.key.localizedLowercase)