Skip to content

Commit

Permalink
Merge pull request #19 from joselinoneto/develop
Browse files Browse the repository at this point in the history
try fix async save and main update
  • Loading branch information
joselinoneto authored Mar 4, 2023
2 parents b08b4b4 + 97f0092 commit 61a2c4a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/manager/Controllers/ApodManagerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ public class ApodManagerController {
private func saveItems(_ items: [NasaApodDto]?) async throws {
let itemsAdd: [ApodStorage] = items?.map { ApodStorage($0) } ?? []
for item in itemsAdd {
try await storageController.asyncSaveItem(item)
guard let id = item.id else { return }
if try storageController.getApod(id: id) == nil {
if #available(macOS 13.0, *) {
try await Task.sleep(for: Duration.seconds(0.5))
}
try await storageController.asyncSaveItem(item)
}
}
}

Expand Down

0 comments on commit 61a2c4a

Please sign in to comment.