make database write async at the call site and update tests

This commit is contained in:
Bryan Montz
2023-05-25 09:09:50 -05:00
parent 7259641e26
commit 61ff7da2ae
3 changed files with 41 additions and 36 deletions

View File

@@ -37,10 +37,12 @@ class Profiles {
self.profiles[id] = profile
}
do {
try database.upsert(id: id, profile: profile.profile, last_update: Date(timeIntervalSince1970: TimeInterval(profile.timestamp)))
} catch {
print("⚠️ Warning: Profiles failed to save a profile: \(error)")
Task {
do {
try await database.upsert(id: id, profile: profile.profile, last_update: Date(timeIntervalSince1970: TimeInterval(profile.timestamp)))
} catch {
print("⚠️ Warning: Profiles failed to save a profile: \(error)")
}
}
}