mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-04 18:15:01 +02:00
Update:iOS using new sync local sessions endpoint
- remove local session sync function call on starting playback - Add User model and getCurrentUser api function
This commit is contained in:
parent
ff5a1bb09f
commit
36be91962c
12 changed files with 128 additions and 97 deletions
41
ios/App/Shared/models/server/User.swift
Normal file
41
ios/App/Shared/models/server/User.swift
Normal file
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// User.swift
|
||||
// Audiobookshelf
|
||||
//
|
||||
// Created by advplyr on 11/12/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import RealmSwift
|
||||
|
||||
class User: EmbeddedObject, Codable {
|
||||
@Persisted var id: String = ""
|
||||
@Persisted var username: String = ""
|
||||
@Persisted var mediaProgress = List<MediaProgress>()
|
||||
|
||||
private enum CodingKeys : String, CodingKey {
|
||||
case id, username, mediaProgress
|
||||
}
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
}
|
||||
|
||||
required init(from decoder: Decoder) throws {
|
||||
super.init()
|
||||
|
||||
let values = try decoder.container(keyedBy: CodingKeys.self)
|
||||
id = try values.decode(String.self, forKey: .id)
|
||||
username = try values.decode(String.self, forKey: .username)
|
||||
if let progresses = try? values.decode([MediaProgress].self, forKey: .mediaProgress) {
|
||||
mediaProgress.append(objectsIn: progresses)
|
||||
}
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(id, forKey: .id)
|
||||
try container.encode(username, forKey: .username)
|
||||
try container.encode(Array(mediaProgress), forKey: .mediaProgress)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue