mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2025-08-02 00:54:30 +02:00
Refactor storage model to work with native Realm
This commit is contained in:
parent
b0905d0270
commit
d83e04c47b
33 changed files with 1580 additions and 1305 deletions
46
ios/App/Shared/models/local/LocalPodcastEpisode.swift
Normal file
46
ios/App/Shared/models/local/LocalPodcastEpisode.swift
Normal file
|
@ -0,0 +1,46 @@
|
|||
//
|
||||
// LocalPodcastEpisode.swift
|
||||
// App
|
||||
//
|
||||
// Created by Ron Heft on 8/16/22.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import RealmSwift
|
||||
|
||||
class LocalPodcastEpisode: Object, Codable {
|
||||
@Persisted(primaryKey: true) var id: String = UUID().uuidString
|
||||
@Persisted var index: Int = 0
|
||||
@Persisted var episode: String?
|
||||
@Persisted var episodeType: String?
|
||||
@Persisted var title: String = "Unknown"
|
||||
@Persisted var subtitle: String?
|
||||
@Persisted var desc: String?
|
||||
@Persisted var audioFile: AudioFile?
|
||||
@Persisted var audioTrack: AudioTrack?
|
||||
@Persisted var duration: Double = 0
|
||||
@Persisted var size: Int = 0
|
||||
@Persisted(indexed: true) var serverEpisodeId: String?
|
||||
|
||||
private enum CodingKeys : String, CodingKey {
|
||||
case id
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: CodingKeys.self)
|
||||
try container.encode(id, forKey: .id)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue