mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 18:15:01 +02:00
Fix crashes related to Realm threading
This commit is contained in:
parent
8ce0d9ce56
commit
b0905d0270
8 changed files with 236 additions and 75 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue