mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
Swift
31 lines
1.0 KiB
Swift
2 years ago
|
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||
|
|
||
|
import Foundation
|
||
|
import GRDB
|
||
|
import SignalCoreKit
|
||
|
import SessionUtilitiesKit
|
||
|
|
||
|
public enum RetrieveDefaultOpenGroupRoomsJob: JobExecutor {
|
||
|
public static let maxFailureCount: Int = -1
|
||
|
public static let requiresThreadId: Bool = false
|
||
|
public static let requiresInteractionId: Bool = false
|
||
|
|
||
|
public static func run(
|
||
|
_ job: Job,
|
||
|
success: @escaping (Job, Bool) -> (),
|
||
|
failure: @escaping (Job, Error?, Bool) -> (),
|
||
|
deferred: @escaping (Job) -> ()
|
||
|
) {
|
||
|
// Don't run when inactive or not in main app
|
||
|
guard (UserDefaults.sharedLokiProject?[.isMainAppActive]).defaulting(to: false) else {
|
||
|
deferred(job) // Don't need to do anything if it's not the main app
|
||
|
return
|
||
|
}
|
||
|
|
||
|
OpenGroupAPIV2.getDefaultRoomsIfNeeded()
|
||
|
.done { _ in success(job, false) }
|
||
|
.catch { error in failure(job, error, false) }
|
||
|
.retainUntilComplete()
|
||
|
}
|
||
|
}
|