mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-07-21 11:14:38 +02:00
API functions to sync local progress
This commit is contained in:
parent
f4e39ec7ca
commit
8d38f3358e
5 changed files with 218 additions and 10 deletions
|
@ -6,8 +6,8 @@
|
|||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import RealmSwift
|
||||
import Capacitor
|
||||
|
||||
extension String: Error {}
|
||||
|
||||
|
@ -31,6 +31,14 @@ extension Collection where Iterator.Element: Encodable {
|
|||
}
|
||||
}
|
||||
|
||||
extension CAPPluginCall {
|
||||
func getJson<T: Decodable>(_ key: String, type: T.Type) -> T? {
|
||||
guard let value = getString(key) else { return nil }
|
||||
guard let valueData = value.data(using: .utf8) else { return nil }
|
||||
return try? JSONDecoder().decode(type, from: valueData)
|
||||
}
|
||||
}
|
||||
|
||||
extension DispatchQueue {
|
||||
static func runOnMainQueue(callback: @escaping (() -> Void)) {
|
||||
if Thread.isMainThread {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue