mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-08-10 21:59:23 +02:00
API functions to sync local progress
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user