Maybe fix crash in sceneDidEnterBackground

This commit is contained in:
Shadowfacts 2022-06-07 16:29:30 -04:00
parent b4675a97c7
commit 6d6fd3d49d
1 changed files with 4 additions and 1 deletions

View File

@ -123,7 +123,10 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate {
rootVC.sceneDidEnterBackground()
}
if let context = scene.session.mastodonController?.persistentContainer.viewContext {
if let context = scene.session.mastodonController?.persistentContainer.viewContext,
// if the user quickly opens and then closes the app, this may race with loading the persistent store, so in that event we skip cleanup/save
let psc = context.persistentStoreCoordinator,
!psc.persistentStores.isEmpty {
var minDate = Date()
minDate.addTimeInterval(-7 * 24 * 60 * 60)