From 229f1604f0d9810fd5e59a2950f22d10212a9cdb Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Thu, 28 Nov 2019 14:59:45 -0600 Subject: [PATCH] Enable ShowDebugMenu on master --- Mac/AppDefaults.swift | 14 +++++++++++++- Mac/AppDelegate.swift | 21 ++++++++++++++------- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index d5eef0fe3..44219001f 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -34,6 +34,7 @@ struct AppDefaults { static let exportOPMLAccountID = "exportOPMLAccountID" // Hidden prefs + static let showDebugMenu = "ShowDebugMenu" static let timelineShowsSeparators = "CorreiaSeparators" static let showTitleOnMainWindow = "KafasisTitleMode" static let hideDockUnreadCount = "JustinMillerHideDockUnreadCount" @@ -149,6 +150,10 @@ struct AppDefaults { return bool(for: Key.showTitleOnMainWindow) } + static var showDebugMenu: Bool { + return bool(for: Key.showDebugMenu) + } + static var hideDockUnreadCount: Bool { return bool(for: Key.hideDockUnreadCount) } @@ -215,6 +220,12 @@ struct AppDefaults { } static func registerDefaults() { + #if DEBUG + let showDebugMenu = true + #else + let showDebugMenu = false + #endif + let defaults: [String : Any] = [Key.lastImageCacheFlushDate: Date(), Key.sidebarFontSize: FontSize.medium.rawValue, Key.timelineFontSize: FontSize.medium.rawValue, @@ -222,7 +233,8 @@ struct AppDefaults { Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, Key.timelineGroupByFeed: false, "NSScrollViewShouldScrollUnderTitlebar": false, - Key.refreshInterval: RefreshInterval.everyHour.rawValue] + Key.refreshInterval: RefreshInterval.everyHour.rawValue, + Key.showDebugMenu: showDebugMenu] UserDefaults.standard.register(defaults: defaults) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index b9eba6e9d..79296e81d 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -220,18 +220,25 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenter.current().delegate = self userNotificationManager = UserNotificationManager() - #if RELEASE + if AppDefaults.showDebugMenu { + refreshTimer!.update() + syncTimer!.update() + + // The Web Inspector uses SPI and can never appear in a MAC_APP_STORE build. + #if MAC_APP_STORE + let debugMenu = debugMenuItem.submenu! + let toggleWebInspectorItemIndex = debugMenu.indexOfItem(withTarget: self, andAction: #selector(toggleWebInspectorEnabled(_:))) + if toggleWebInspectorItemIndex != -1 { + debugMenu.removeItem(at: toggleWebInspectorItemIndex) + } + #endif + } else { debugMenuItem.menu?.removeItem(debugMenuItem) DispatchQueue.main.async { self.refreshTimer!.timedRefresh(nil) self.syncTimer!.timedRefresh(nil) } - #endif - - #if DEBUG - refreshTimer!.update() - syncTimer!.update() - #endif + } #if !MAC_APP_STORE DispatchQueue.main.async {