From f53ce940495d9723674661b9f08e9a1ea113e867 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 31 May 2023 19:08:09 +0800 Subject: [PATCH] Add a logout option --- apple/InfoPlists/MacOmnivore.plist | 2 ++ apple/Omnivore.xcodeproj/project.pbxproj | 8 ++++---- apple/OmnivoreKit/Sources/App/MacMenuCommands.swift | 5 +++++ .../Sources/App/Views/Home/HomeFeedViewMac.swift | 5 +++++ .../Sources/Services/NSNotification+Operation.swift | 9 +++++++++ apple/OmnivoreKit/Sources/Views/LocalText.swift | 1 + 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/apple/InfoPlists/MacOmnivore.plist b/apple/InfoPlists/MacOmnivore.plist index d18829a1d..c2b3483f0 100644 --- a/apple/InfoPlists/MacOmnivore.plist +++ b/apple/InfoPlists/MacOmnivore.plist @@ -2,6 +2,8 @@ + ITSAppUsesNonExemptEncryption + CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable diff --git a/apple/Omnivore.xcodeproj/project.pbxproj b/apple/Omnivore.xcodeproj/project.pbxproj index 71f95bc8c..6e02bb21e 100644 --- a/apple/Omnivore.xcodeproj/project.pbxproj +++ b/apple/Omnivore.xcodeproj/project.pbxproj @@ -1388,7 +1388,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 82; + CURRENT_PROJECT_VERSION = 90; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; @@ -1400,7 +1400,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 1.24.0; + MARKETING_VERSION = 1.27.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; @@ -1423,7 +1423,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 82; + CURRENT_PROJECT_VERSION = 90; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = QJF2XZ86HB; @@ -1435,7 +1435,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 12.0; - MARKETING_VERSION = 1.24.0; + MARKETING_VERSION = 1.27.0; MTL_FAST_MATH = YES; PRODUCT_BUNDLE_IDENTIFIER = app.omnivore.app; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift index 72250e257..4f9567126 100644 --- a/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift +++ b/apple/OmnivoreKit/Sources/App/MacMenuCommands.swift @@ -142,6 +142,11 @@ import Views } }) } + CommandGroup(after: .appTermination) { + Button("Logout", action: { + NSNotification.logout() + }) + } CommandMenu("Reader Display") { spacingButtons diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index 566d451d5..fa14d1faf 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -9,6 +9,8 @@ import Views struct HomeFeedView: View { @EnvironmentObject var dataService: DataService @EnvironmentObject var audioController: AudioController + @EnvironmentObject var authenticator: Authenticator + @State private var itemToRemove: LinkedItem? @State private var confirmationShown = false @State private var presentProfileSheet = false @@ -151,6 +153,9 @@ import Views .onReceive(NSNotification.displayProfilePublisher) { _ in presentProfileSheet = true } + .onReceive(NSNotification.logoutPublisher) { _ in + authenticator.logout(dataService: dataService) + } .task { if viewModel.items.isEmpty { loadItems(isRefresh: true) diff --git a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift index 45296f027..2a94c20bd 100644 --- a/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift +++ b/apple/OmnivoreKit/Sources/Services/NSNotification+Operation.swift @@ -10,6 +10,7 @@ public extension NSNotification { static let ReaderSettingsChanged = Notification.Name("ReaderSettingsChanged") static let SpeakingReaderItem = Notification.Name("SpeakingReaderItem") static let DisplayProfile = Notification.Name("DisplayProfile") + static let Logout = Notification.Name("Logout") static var pushFeedItemPublisher: NotificationCenter.Publisher { NotificationCenter.default.publisher(for: PushJSONArticle) @@ -39,6 +40,10 @@ public extension NSNotification { NotificationCenter.default.publisher(for: DisplayProfile) } + static var logoutPublisher: NotificationCenter.Publisher { + NotificationCenter.default.publisher(for: Logout) + } + internal var operationMessage: String? { if let message = userInfo?["message"] as? String { return message @@ -74,6 +79,10 @@ public extension NSNotification { NotificationCenter.default.post(name: NSNotification.ReaderSettingsChanged, object: nil) } + static func logout() { + NotificationCenter.default.post(name: NSNotification.Logout, object: nil) + } + static func displayProfile() { NotificationCenter.default.post(name: NSNotification.DisplayProfile, object: nil) } diff --git a/apple/OmnivoreKit/Sources/Views/LocalText.swift b/apple/OmnivoreKit/Sources/Views/LocalText.swift index 86ebd4499..13a5ba82c 100644 --- a/apple/OmnivoreKit/Sources/Views/LocalText.swift +++ b/apple/OmnivoreKit/Sources/Views/LocalText.swift @@ -165,6 +165,7 @@ public enum LocalText { public static let genericFontFamily = localText(key: "genericFontFamily") public static let genericHighContrastText = localText(key: "genericHighContrastText") public static let enableJustifyText = localText(key: "enableJustifyText") + public static let enableHighlightOnReleaseText = localText(key: "enableHighlightOnReleaseText") public static let genericFont = localText(key: "genericFont") public static let genericHighlight = localText(key: "genericHighlight") public static let labelsGeneric = localText(key: "labelsGeneric")