Remove apps from the database when they are removed from the app list

This commit is contained in:
Cameron Gutman
2016-01-21 16:24:02 -05:00
parent 2ec7d1d2f1
commit 0ae58c61a9
3 changed files with 16 additions and 0 deletions

View File

@@ -21,6 +21,7 @@
- (void) updateAppsForExistingHost:(TemporaryHost *)host;
- (void) updateIconForExistingApp:(TemporaryApp*)app;
- (void) removeHost:(TemporaryHost*)host;
- (void) removeApp:(TemporaryApp*)app;
- (TemporarySettings*) getSettings;

View File

@@ -140,6 +140,16 @@
}
}
- (void) removeApp:(TemporaryApp*)app {
[_managedObjectContext performBlockAndWait:^{
App* managedApp = [self getAppForTemporaryApp:app];
if (managedApp != nil) {
[_managedObjectContext deleteObject:managedApp];
[self saveData];
}
}];
}
- (void) removeHost:(TemporaryHost*)host {
[_managedObjectContext performBlockAndWait:^{
Host* managedHost = [self getHostForTemporaryHost:host];

View File

@@ -195,6 +195,11 @@ static NSMutableSet* hostList;
[host.appList removeObject:app];
// It's important to remove the app record from the database
// since we'll have a constraint violation now that appList
// doesn't have this app in it.
[database removeApp:app];
break;
}
}