From e8fa409cef7502e53afd9f1a43599613c5fceba9 Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Wed, 24 Apr 2019 12:06:16 +0200 Subject: [PATCH] =?UTF-8?q?moved=20observation=20to=20init=20since=20it?= =?UTF-8?q?=E2=80=99s=20need=20from=20the=20start?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MacPass/MPAppDelegate.m | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/MacPass/MPAppDelegate.m b/MacPass/MPAppDelegate.m index 4062902d..d9d364d9 100644 --- a/MacPass/MPAppDelegate.m +++ b/MacPass/MPAppDelegate.m @@ -82,11 +82,21 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi if(self) { _userNotificationCenterDelegate = [[MPUserNotificationCenterDelegate alloc] init]; self.itemActionMenuDelegate = [[MPEntryContextMenuDelegate alloc] init]; + _shouldOpenFile = NO; + + [NSNotificationCenter.defaultCenter addObserver:self + selector:@selector(_applicationDidFinishRestoringWindows:) + name:NSApplicationDidFinishRestoringWindowsNotification + object:nil]; + /* We know that we do not use the variable after instantiation */ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-variable" MPDocumentController *documentController = [[MPDocumentController alloc] init]; #pragma clang diagnostic pop + + + } return self; } @@ -156,12 +166,6 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi - (void)applicationWillFinishLaunching:(NSNotification *)notification { - _shouldOpenFile = NO; - [NSNotificationCenter.defaultCenter addObserver:self - selector:@selector(_applicationDidFinishRestoringWindows:) - name:NSApplicationDidFinishRestoringWindowsNotification - object:nil]; - } @@ -170,6 +174,7 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi } - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { + [self hideWelcomeWindow]; if([[MPTemporaryFileStorageCenter defaultCenter] hasPendingStorages]) { dispatch_async(dispatch_get_main_queue(), ^{ [MPTemporaryFileStorageCenter.defaultCenter cleanupStorages]; @@ -285,11 +290,13 @@ NSString *const MPDidChangeStoredKeyFilesSettings = @"com.hicknhack.macpass.MPDi } - (void)showWelcomeWindow { + NSApp.dockTile.badgeLabel = @"WELCOME"; if(!self.welcomeWindow) { self.welcomeWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 100, 100) styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO]; + self.welcomeWindow.restorable = NO; // do not restore the welcome window! self.welcomeWindow.releasedWhenClosed = NO; } if(!self.welcomeWindow.contentViewController) {