mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Caching for favorites
This commit is contained in:
@@ -40,7 +40,7 @@ struct Playlist: Identifiable, Equatable, Hashable {
|
||||
}
|
||||
|
||||
var json: JSON {
|
||||
return [
|
||||
[
|
||||
"id": id,
|
||||
"title": title,
|
||||
"visibility": visibility.rawValue,
|
||||
@@ -51,7 +51,7 @@ struct Playlist: Identifiable, Equatable, Hashable {
|
||||
}
|
||||
|
||||
static func from(_ json: JSON) -> Self {
|
||||
return .init(
|
||||
.init(
|
||||
id: json["id"].stringValue,
|
||||
title: json["title"].stringValue,
|
||||
visibility: .init(rawValue: json["visibility"].stringValue) ?? .public,
|
||||
|
@@ -38,13 +38,15 @@ final class PlaylistsModel: ObservableObject {
|
||||
}
|
||||
|
||||
func load(force: Bool = false, onSuccess: @escaping () -> Void = {}) {
|
||||
guard accounts.app.supportsUserPlaylists, accounts.signedIn, let account = accounts.current else {
|
||||
guard accounts.app.supportsUserPlaylists, let account = accounts.current else {
|
||||
playlists = []
|
||||
return
|
||||
}
|
||||
|
||||
loadCachedPlaylists(account)
|
||||
|
||||
guard accounts.signedIn else { return }
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self else { return }
|
||||
let request = force ? self.resource?.load() : self.resource?.loadIfNeeded()
|
||||
|
Reference in New Issue
Block a user