mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-08 22:33:26 +01:00
Adds support for “deleting” installed apps
Temporary, because later we won’t be able to actually uninstall apps from within AltStore
This commit is contained in:
@@ -38,6 +38,7 @@ private extension MyAppsViewController
|
|||||||
fetchRequest.returnsObjectsAsFaults = false
|
fetchRequest.returnsObjectsAsFaults = false
|
||||||
|
|
||||||
let dataSource = RSTFetchedResultsTableViewDataSource(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext)
|
let dataSource = RSTFetchedResultsTableViewDataSource(fetchRequest: fetchRequest, managedObjectContext: DatabaseManager.shared.viewContext)
|
||||||
|
dataSource.proxy = self
|
||||||
dataSource.cellConfigurationHandler = { (cell, installedApp, indexPath) in
|
dataSource.cellConfigurationHandler = { (cell, installedApp, indexPath) in
|
||||||
guard let app = installedApp.app else { return }
|
guard let app = installedApp.app else { return }
|
||||||
|
|
||||||
@@ -56,3 +57,27 @@ private extension MyAppsViewController
|
|||||||
return dataSource
|
return dataSource
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension MyAppsViewController
|
||||||
|
{
|
||||||
|
override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath)
|
||||||
|
{
|
||||||
|
guard editingStyle == .delete else { return }
|
||||||
|
|
||||||
|
let installedApp = self.dataSource.item(at: indexPath)
|
||||||
|
|
||||||
|
DatabaseManager.shared.persistentContainer.performBackgroundTask { (context) in
|
||||||
|
let installedApp = context.object(with: installedApp.objectID) as! InstalledApp
|
||||||
|
context.delete(installedApp)
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
try context.save()
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
print("Failed to delete installed app.", error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user