Fix crashes related to Realm threading

This commit is contained in:
ronaldheft 2022-08-16 12:32:22 -04:00
parent 8ce0d9ce56
commit b0905d0270
8 changed files with 236 additions and 75 deletions

View file

@ -167,13 +167,14 @@ class ApiClient {
}
public static func reportLocalMediaProgress(_ localMediaProgress: LocalMediaProgress, callback: @escaping (_ success: Bool) -> Void) {
postResource(endpoint: "api/session/local", parameters: localMediaProgress, callback: callback)
let progress = localMediaProgress.freeze()
postResource(endpoint: "api/session/local", parameters: progress, callback: callback)
}
public static func syncMediaProgress(callback: @escaping (_ results: LocalMediaProgressSyncResultsPayload) -> Void) {
let localMediaProgressList = Database.shared.getAllLocalMediaProgress().filter {
$0.serverConnectionConfigId == Store.serverConfig?.id
}
}.map { $0.freeze() }
if ( !localMediaProgressList.isEmpty ) {
let payload = LocalMediaProgressSyncPayload(localMediaProgress: localMediaProgressList)

View file

@ -197,4 +197,9 @@ class Database {
realm.delete(progress!)
}
}
public func getPlaybackSession(id: String) -> PlaybackSession? {
let realm = try! Realm()
return realm.object(ofType: PlaybackSession.self, forPrimaryKey: id)
}
}