Report download progress to the UI

This commit is contained in:
ronaldheft 2022-08-06 18:21:11 -04:00
parent d5d65e244b
commit af2c609405
3 changed files with 47 additions and 7 deletions

View file

@ -169,6 +169,20 @@ class Database {
}
}
public func updateDownloadItemPartPercent(downloadItemPartId: String, percent: Double) {
Database.realmQueue.sync {
try! instance.write {
let part = instance.object(ofType: DownloadItemPart.self, forPrimaryKey: downloadItemPartId)
guard var part = part else {
NSLog("downloadItemPartId not found (\(downloadItemPartId)")
return
}
part.progress = percent
instance.add(part, update: .modified)
}
}
}
public func getDeviceSettings() -> DeviceSettings {
return Database.realmQueue.sync {
return instance.objects(DeviceSettings.self).first ?? getDefaultDeviceSettings()