fix(ios): keep a crawl running when the app leaves the screen

Without a background task iOS suspends the app at once and drops its
connections, so a glance at another app failed a minutes-long crawl.
This commit is contained in:
nvrl committed 2026-10-13 20:45:14 +02:00
1 parent 85bc975f5f
commit c44b04cf4a
1 file changed
+6
+6
View File
@@ -152,10 +152,16 @@ final class AppModel {
}
/// Crawl one share, or all with nil, with the banner offering Stop meanwhile.
///
/// Held under a background task: a crawl takes minutes, and without one
/// iOS suspends the app the moment it leaves the screen and tears down its
/// connections, so a glance at another app failed the crawl.
private func crawlShares(_ id: String?) async throws {
crawlsRunning += 1
crawling = true
let task = BackgroundTask(name: "crawl")
defer {
task.end()
crawlsRunning -= 1
crawling = crawlsRunning > 0
}