Skip to content

Commit 4410fda

Browse files
committed
removed unnessary DispatchQueue.main.async in DatasyncManager as syncDataToOSM completion block already moved and running on the main thread
- syncData method removed as MainActor. As realm object is creating when we are using. MainActor action is no need as no chance of thread switch in accessing realm object
1 parent af1a98b commit 4410fda

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

GoInfoGame/GoInfoGame/data/DatasyncManager.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,14 @@ class DatasyncManager {
3232
print("Sync finished")
3333
if isSynced {
3434
print("Sync successful")
35-
DispatchQueue.main.async {
36-
completionHandler(.success(true)) // Success
37-
}
35+
completionHandler(.success(true)) // Success
3836
} else {
3937
print("Sync failed")
40-
DispatchQueue.main.async {
41-
completionHandler(.failure(APIError.custom("Sync failed. Please try again."))) // Failure
42-
}
38+
completionHandler(.failure(APIError.custom("Sync failed. Please try again."))) // Failure
4339
}
4440
} catch {
4541
print("Sync failed: \(error)")
46-
DispatchQueue.main.async {
47-
completionHandler(.failure(error as! APIError)) // Failure
48-
}
42+
completionHandler(.failure(error as! APIError)) // Failure
4943
}
5044
semaphore.signal()
5145
}
@@ -56,7 +50,6 @@ class DatasyncManager {
5650

5751
/// *** Terminating app due to uncaught exception 'RLMException', reason: 'Realm accessed from incorrect thread.'
5852
/// To fix the above error added @mainActor
59-
@MainActor
6053
func syncData(exclude_gig_tags: Bool = false) async throws -> Bool {
6154
print("🔄 Starting sync...")
6255

0 commit comments

Comments
 (0)