-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2348d06
commit 51ef4ce
Showing
19 changed files
with
504 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Marlin/Marlin/Network/DifferentialGPSStation/DifferentialGPSStationDataLoadOperation.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// DifferentialGPSStationDataLoadOperation.swift | ||
// Marlin | ||
// | ||
// Created by Daniel Barela on 2/1/24. | ||
// | ||
|
||
import Foundation | ||
import CoreData | ||
|
||
class DifferentialGPSStationDataLoadOperation: CountingDataLoadOperation { | ||
|
||
var dgpss: [DifferentialGPSStationModel] = [] | ||
var localDataSource: DifferentialGPSStationLocalDataSource | ||
|
||
init(dgpss: [DifferentialGPSStationModel], localDataSource: DifferentialGPSStationLocalDataSource) { | ||
self.dgpss = dgpss | ||
self.localDataSource = localDataSource | ||
} | ||
|
||
override func loadData() async { | ||
if self.isCancelled { | ||
return | ||
} | ||
|
||
count = (try? await localDataSource.batchImport(from: dgpss)) ?? 0 | ||
if count != 0 { | ||
DispatchQueue.main.async { | ||
NotificationCenter.default.post( | ||
name: .DataSourceNeedsProcessed, | ||
object: DataSourceUpdatedNotification(key: DataSources.dgps.key) | ||
) | ||
NotificationCenter.default.post( | ||
name: .DataSourceUpdated, | ||
object: DataSourceUpdatedNotification(key: DataSources.dgps.key) | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.