From 3887a8902e8c314003a1a4e62ea1249336e996c5 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 3 Feb 2025 16:44:26 +1100 Subject: [PATCH] Fixed a crash which could occur when leaving the conversation screen --- Session/Meta/MainAppContext.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Session/Meta/MainAppContext.swift b/Session/Meta/MainAppContext.swift index 4f917da59..3ee8d2a59 100644 --- a/Session/Meta/MainAppContext.swift +++ b/Session/Meta/MainAppContext.swift @@ -154,6 +154,12 @@ final class MainAppContext: AppContext { // stringlint:ignore_contents func ensureSleepBlocking(_ shouldBeBlocking: Bool, blockingObjects: [Any]) { + guard Thread.isMainThread else { + return DispatchQueue.main.async { [weak self] in + self?.ensureSleepBlocking(shouldBeBlocking, blockingObjects: blockingObjects) + } + } + if UIApplication.shared.isIdleTimerDisabled != shouldBeBlocking { if shouldBeBlocking { var logString: String = "Blocking sleep because of: \(String(describing: blockingObjects.first))"