mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-11-03 16:41:26 +01:00
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:
1 parent
85bc975f5f
commit
c44b04cf4a
1 file changed
+6
@@ -152,10 +152,16 @@ final class AppModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Crawl one share, or all with nil, with the banner offering Stop meanwhile.
|
/// 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 {
|
private func crawlShares(_ id: String?) async throws {
|
||||||
crawlsRunning += 1
|
crawlsRunning += 1
|
||||||
crawling = true
|
crawling = true
|
||||||
|
let task = BackgroundTask(name: "crawl")
|
||||||
defer {
|
defer {
|
||||||
|
task.end()
|
||||||
crawlsRunning -= 1
|
crawlsRunning -= 1
|
||||||
crawling = crawlsRunning > 0
|
crawling = crawlsRunning > 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user