From 3d8f470206e42e7587e970bbef143a30a1ce74d2 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Tue, 21 Jun 2022 16:15:50 -0700 Subject: [PATCH] [Sandbox Configuration] Delete from storage later Only delete from storage after deleting it from the UI list. Signed-off-by: Christopher Snowhill --- .../SandboxPathBehaviorController.m | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Preferences/Preferences/SandboxPathBehaviorController.m b/Preferences/Preferences/SandboxPathBehaviorController.m index 40e682ef2..3b32710b9 100644 --- a/Preferences/Preferences/SandboxPathBehaviorController.m +++ b/Preferences/Preferences/SandboxPathBehaviorController.m @@ -77,6 +77,15 @@ } - (void)removePath:(NSString *)path { + NSArray *objects = [[self arrangedObjects] copy]; + + for(NSDictionary *obj in objects) { + if([[obj objectForKey:@"path"] isEqualToString:path]) { + [self removeObject:obj]; + break; + } + } + NSPersistentContainer *pc = [NSClassFromString(@"PlaylistController") sharedPersistentContainer]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"path == %@", path]; @@ -92,14 +101,10 @@ [pc.viewContext deleteObject:token]; } } - - NSArray *objects = [self arrangedObjects]; - - for(NSDictionary *obj in objects) { - if([[obj objectForKey:@"path"] isEqualToString:path]) { - [self removeObject:obj]; - break; - } + + [pc.viewContext save:&error]; + if(error) { + ALog(@"Error deleting bookmark: %@", [error localizedDescription]); } }