Fixed an issue preventing notifications from working
Fixed an issue where Storage could be left in an invalid state when it was completed silently before properly getting setup
This commit is contained in:
parent
5285d81177
commit
c63a9d3994
|
@ -227,6 +227,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|||
// to process new messages.
|
||||
guard !didPerformSetup else { return }
|
||||
|
||||
NSLog("[NotificationServiceExtension] Performing setup")
|
||||
didPerformSetup = true
|
||||
|
||||
_ = AppVersion.sharedInstance()
|
||||
|
@ -243,7 +244,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|||
switch result {
|
||||
// Only 'NSLog' works in the extension - viewable via Console.app
|
||||
case .failure(let error):
|
||||
NSLog("[NotificationServiceExtension] Failed to complete migrations")
|
||||
NSLog("[NotificationServiceExtension] Failed to complete migrations: \(error)")
|
||||
self?.completeSilenty()
|
||||
|
||||
case .success:
|
||||
|
@ -288,7 +289,11 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|||
guard !AppReadiness.isAppReady() else { return }
|
||||
|
||||
// App isn't ready until storage is ready AND all version migrations are complete.
|
||||
guard Storage.shared.isValid && migrationsCompleted else { return }
|
||||
guard Storage.shared.isValid && migrationsCompleted else {
|
||||
NSLog("[NotificationServiceExtension] Storage invalid")
|
||||
self.completeSilenty()
|
||||
return
|
||||
}
|
||||
|
||||
SignalUtilitiesKit.Configuration.performMainSetup()
|
||||
|
||||
|
@ -305,8 +310,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
|||
}
|
||||
|
||||
private func completeSilenty() {
|
||||
SNLog("Complete silenty")
|
||||
|
||||
NSLog("[NotificationServiceExtension] Complete silently")
|
||||
Storage.suspendDatabaseAccess()
|
||||
|
||||
self.contentHandler!(.init())
|
||||
|
|
|
@ -375,14 +375,14 @@ open class Storage {
|
|||
/// database and other files into the App folder
|
||||
public static func suspendDatabaseAccess(using dependencies: Dependencies = Dependencies()) {
|
||||
NotificationCenter.default.post(name: Database.suspendNotification, object: self)
|
||||
dependencies.storage.isSuspendedUnsafe = true
|
||||
if Storage.hasCreatedValidInstance { dependencies.storage.isSuspendedUnsafe = true }
|
||||
}
|
||||
|
||||
/// This method reverses the database suspension used to prevent the `0xdead10cc` exception (see `suspendDatabaseAccess()`
|
||||
/// above for more information
|
||||
public static func resumeDatabaseAccess(using dependencies: Dependencies = Dependencies()) {
|
||||
NotificationCenter.default.post(name: Database.resumeNotification, object: self)
|
||||
dependencies.storage.isSuspendedUnsafe = false
|
||||
if Storage.hasCreatedValidInstance { dependencies.storage.isSuspendedUnsafe = false }
|
||||
}
|
||||
|
||||
public static func resetAllStorage() {
|
||||
|
|
Loading…
Reference in New Issue