From 24164d501e17034a1451a2a13070262c8860c1ef Mon Sep 17 00:00:00 2001 From: Michael Starke Date: Fri, 7 Oct 2022 11:20:30 +0200 Subject: [PATCH] remove unnecessary code duplication --- MacPass/MPLockDaemon.m | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/MacPass/MPLockDaemon.m b/MacPass/MPLockDaemon.m index 29f9d613..a746d53a 100644 --- a/MacPass/MPLockDaemon.m +++ b/MacPass/MPLockDaemon.m @@ -77,7 +77,7 @@ static MPLockDaemon *_sharedInstance; if(_lockOnLogout != lockOnLogout) { _lockOnLogout = lockOnLogout; if(_lockOnLogout) { - [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_willLogOutNotification:) name:NSWorkspaceSessionDidResignActiveNotification object:nil]; + [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_lockDocumentsForNotification:) name:NSWorkspaceSessionDidResignActiveNotification object:nil]; } else { [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:@"" object:nil]; @@ -89,7 +89,7 @@ static MPLockDaemon *_sharedInstance; if(_lockOnSleep != lockOnSleep) { _lockOnSleep = lockOnSleep; if(_lockOnSleep) { - [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_willSleepNotification:) name:NSWorkspaceWillSleepNotification object:nil]; + [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_lockDocumentsForNotification:) name:NSWorkspaceWillSleepNotification object:nil]; } else { [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:NSWorkspaceWillSleepNotification object:nil]; @@ -101,7 +101,7 @@ static MPLockDaemon *_sharedInstance; if(_lockOnScreenSleep != lockOnScreenSleep) { _lockOnScreenSleep = lockOnScreenSleep; if(_lockOnScreenSleep) { - [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_willScreenSleepNotification:) name:NSWorkspaceScreensDidSleepNotification object:nil]; + [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(_lockDocumentsForNotification:) name:NSWorkspaceScreensDidSleepNotification object:nil]; } else { [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self name:NSWorkspaceScreensDidSleepNotification object:nil]; @@ -120,14 +120,7 @@ static MPLockDaemon *_sharedInstance; } } } - -- (void)_willLogOutNotification:(NSNotification *)notification { - [((MPAppDelegate *)NSApp.delegate) lockAllDocuments]; -} -- (void)_willSleepNotification:(NSNotification *)notification { - [((MPAppDelegate *)NSApp.delegate) lockAllDocuments]; -} -- (void)_willScreenSleepNotification:(NSNotification *)notification { +- (void)_lockDocumentsForNotification:(NSNotification *)notification { [((MPAppDelegate *)NSApp.delegate) lockAllDocuments]; }