From 2add3f694377179d25af1c80fdcec0f650af12cf Mon Sep 17 00:00:00 2001 From: jacklinw Date: Mon, 6 Aug 2018 00:22:35 -0700 Subject: [PATCH 1/8] Add confirmation model to pull action --- .../SwitcherMediaPoolAppDelegate.m | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index a79d35f..6043e66 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -218,9 +218,17 @@ -(void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol [mw pushStills]; } } else if([identifier isEqualToString:@"pull"]) { - if (![mw isBusy] && [mw isConnected]) { - [mw pullStills]; - } + NSAlert *alert = [NSAlert alertWithMessageText:@"Are you sure?" + defaultButton:@"Yes" alternateButton:@"Cancel" + otherButton:nil informativeTextWithFormat: @"Pulling an empty switcher media pool will clobber the switcher state. You probably meant to hit 'Repair'."]; + [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { + if (returnCode == NSAlertFirstButtonReturn) { + return; + } + if (![mw isBusy] && [mw isConnected]) { + [mw pullStills]; + } + }]; } else if([identifier isEqualToString:@"repair"]) { if (![mw localStillsExist]) { NSBeginAlertSheet(@"Please pull before repairing.", @"OK", nil, nil, _window, nil, nil, nil, nil, @""); @@ -369,4 +377,4 @@ - (void) controlTextDidEndEditing:(NSNotification *)obj { [_interval setStringValue:[[settings objectForKey:@"updateInterval"] stringValue]]; } -@end \ No newline at end of file +@end From 18511f714400b36527e0eb5759951f11fa32d4f2 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 29 Nov 2018 14:34:49 -0800 Subject: [PATCH 2/8] Revert unnecessary newline change --- .../ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index 6043e66..df8e239 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -377,4 +377,4 @@ - (void) controlTextDidEndEditing:(NSNotification *)obj { [_interval setStringValue:[[settings objectForKey:@"updateInterval"] stringValue]]; } -@end +@end \ No newline at end of file From 2378aef12bf081c9193206efcfc31daba53c3880 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 29 Nov 2018 14:41:30 -0800 Subject: [PATCH 3/8] Fix indentation --- .../SwitcherMediaPoolAppDelegate.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index df8e239..d72a837 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -218,9 +218,11 @@ -(void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol [mw pushStills]; } } else if([identifier isEqualToString:@"pull"]) { - NSAlert *alert = [NSAlert alertWithMessageText:@"Are you sure?" - defaultButton:@"Yes" alternateButton:@"Cancel" - otherButton:nil informativeTextWithFormat: @"Pulling an empty switcher media pool will clobber the switcher state. You probably meant to hit 'Repair'."]; + NSAlert* alert = [NSAlert alertWithMessageText:@"Are you sure?" + defaultButton:@"Yes" + alternateButton:@"Cancel" + otherButton:nil + informativeTextWithFormat:@"Pulling an empty switcher media pool will clobber the switcher state. You probably meant to hit 'Repair'."]; [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { if (returnCode == NSAlertFirstButtonReturn) { return; From 4f2fc737348a94b914e859436641094befa72bf0 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 29 Nov 2018 14:41:59 -0800 Subject: [PATCH 4/8] Make cancel the default action There's really no reason one should ever want to proceed at this point. --- .../ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index d72a837..cd5c66c 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -219,8 +219,8 @@ -(void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol } } else if([identifier isEqualToString:@"pull"]) { NSAlert* alert = [NSAlert alertWithMessageText:@"Are you sure?" - defaultButton:@"Yes" - alternateButton:@"Cancel" + defaultButton:@"Cancel" + alternateButton:@"Yes" otherButton:nil informativeTextWithFormat:@"Pulling an empty switcher media pool will clobber the switcher state. You probably meant to hit 'Repair'."]; [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { From f2ad69f9cd5905d8fe83589465d2fbead82675f2 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 29 Nov 2018 15:10:53 -0800 Subject: [PATCH 5/8] Add more logic around pull confirmation Only show confirmation when there are local stills but switcher is empty. --- .../SwitcherMediaPoolAppDelegate.m | 29 ++++++++++--------- .../Xcode Files/MediaPoolWatcher.h | 1 + .../Xcode Files/MediaPoolWatcher.m | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index cd5c66c..e7bd392 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -218,19 +218,22 @@ -(void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol [mw pushStills]; } } else if([identifier isEqualToString:@"pull"]) { - NSAlert* alert = [NSAlert alertWithMessageText:@"Are you sure?" - defaultButton:@"Cancel" - alternateButton:@"Yes" - otherButton:nil - informativeTextWithFormat:@"Pulling an empty switcher media pool will clobber the switcher state. You probably meant to hit 'Repair'."]; - [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { - if (returnCode == NSAlertFirstButtonReturn) { - return; - } - if (![mw isBusy] && [mw isConnected]) { - [mw pullStills]; - } - }]; + // User trying to pull and empty switcher over existing local stills. Double-check they meant to do that. + if ([mw localStillsExist] && [mw stillsCount] == 0) { + NSAlert* alert = [NSAlert alertWithMessageText:@"Are you sure?" + defaultButton:@"Cancel" + alternateButton:@"Continue" + otherButton:nil + informativeTextWithFormat:@"Local stills exist but switcher media pool is empty. Continuing will destroy local stills. (Did you mean to press \"Repair\"?)"]; + [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { + if (returnCode == NSAlertDefaultReturn) { + return; + } + }]; + } + if (![mw isBusy] && [mw isConnected]) { + [mw pullStills]; + } } else if([identifier isEqualToString:@"repair"]) { if (![mw localStillsExist]) { NSBeginAlertSheet(@"Please pull before repairing.", @"OK", nil, nil, _window, nil, nil, nil, nil, @""); diff --git a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h index 3dbb6cb..cc58bca 100644 --- a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h +++ b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h @@ -65,5 +65,6 @@ @property (retain) NSString* mIP; @property (retain) NSString* mPath; @property bool terminating; +@property uint32_t stillsCount; @end diff --git a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m index 0ef434b..859a160 100644 --- a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m +++ b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m @@ -11,6 +11,7 @@ @implementation MediaPoolWatcher @synthesize terminating; +@synthesize stillsCount; @synthesize mIP = _mIP; @synthesize mPath = _mPath; From a452373889e6363fc816bae988f7bcb3d4b5d1d0 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 29 Nov 2018 20:40:26 -0800 Subject: [PATCH 6/8] Turns out stillsCount doesn't give you the count of stills --- .../ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m | 6 +++--- ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h | 1 - ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index e7bd392..76b150e 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -218,13 +218,13 @@ -(void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol [mw pushStills]; } } else if([identifier isEqualToString:@"pull"]) { - // User trying to pull and empty switcher over existing local stills. Double-check they meant to do that. - if ([mw localStillsExist] && [mw stillsCount] == 0) { + // User trying to pull when there are existing local stills. Double-check they meant to do that. + if ([mw localStillsExist]) { NSAlert* alert = [NSAlert alertWithMessageText:@"Are you sure?" defaultButton:@"Cancel" alternateButton:@"Continue" otherButton:nil - informativeTextWithFormat:@"Local stills exist but switcher media pool is empty. Continuing will destroy local stills. (Did you mean to press \"Repair\"?)"]; + informativeTextWithFormat:@"There are existing local stills. Overwrite?\n(Did you mean to press \"Repair\"?)"]; [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { if (returnCode == NSAlertDefaultReturn) { return; diff --git a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h index cc58bca..3dbb6cb 100644 --- a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h +++ b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.h @@ -65,6 +65,5 @@ @property (retain) NSString* mIP; @property (retain) NSString* mPath; @property bool terminating; -@property uint32_t stillsCount; @end diff --git a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m index 859a160..0ef434b 100644 --- a/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m +++ b/ATEM Media Pool Updater/Xcode Files/MediaPoolWatcher.m @@ -11,7 +11,6 @@ @implementation MediaPoolWatcher @synthesize terminating; -@synthesize stillsCount; @synthesize mIP = _mIP; @synthesize mPath = _mPath; From 4f0aab5c2f9ea9f0e774d386de9a91f3438bd193 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 29 Nov 2018 20:49:16 -0800 Subject: [PATCH 7/8] This call is async; need to keep the action inside it --- .../SwitcherMediaPoolAppDelegate.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index 76b150e..a3cb7ed 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -226,14 +226,15 @@ -(void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol otherButton:nil informativeTextWithFormat:@"There are existing local stills. Overwrite?\n(Did you mean to press \"Repair\"?)"]; [alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) { - if (returnCode == NSAlertDefaultReturn) { + if (returnCode == NSAlertAlternateReturn) { + if (![mw isBusy] && [mw isConnected]) { + [mw pullStills]; + } + } else { return; } }]; } - if (![mw isBusy] && [mw isConnected]) { - [mw pullStills]; - } } else if([identifier isEqualToString:@"repair"]) { if (![mw localStillsExist]) { NSBeginAlertSheet(@"Please pull before repairing.", @"OK", nil, nil, _window, nil, nil, nil, nil, @""); From 7f27789256f87880ed565162caa0393247588447 Mon Sep 17 00:00:00 2001 From: Todd Eichel Date: Thu, 29 Nov 2018 21:00:42 -0800 Subject: [PATCH 8/8] We still need to do the thing in the else case too --- .../ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m index a3cb7ed..4eb410f 100644 --- a/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m +++ b/ATEM Media Pool Updater/Xcode Files/ATEM Media Pool Updater/SwitcherMediaPoolAppDelegate.m @@ -234,6 +234,10 @@ -(void) tableView:(NSTableView *)tableView setObjectValue:(id)object forTableCol return; } }]; + } else { + if (![mw isBusy] && [mw isConnected]) { + [mw pullStills]; + } } } else if([identifier isEqualToString:@"repair"]) { if (![mw localStillsExist]) {