diff --git a/Mixonomer/Model/LiveUser.swift b/Mixonomer/Model/LiveUser.swift index a321065..3a5d774 100644 --- a/Mixonomer/Model/LiveUser.swift +++ b/Mixonomer/Model/LiveUser.swift @@ -50,6 +50,11 @@ class LiveUser: ObservableObject { try keychain.remove("username") try keychain.remove("jwt") + playlists.removeAll() + tags.removeAll() + username = "" + user = nil + UserDefaults.standard.removeObject(forKey: "playlists") UserDefaults.standard.removeObject(forKey: "tags") diff --git a/Mixonomer/Views/Playlist/PlaylistList.swift b/Mixonomer/Views/Playlist/PlaylistList.swift index 0d1c277..4ecb051 100644 --- a/Mixonomer/Views/Playlist/PlaylistList.swift +++ b/Mixonomer/Views/Playlist/PlaylistList.swift @@ -20,8 +20,19 @@ struct PlaylistList: View { var body: some View { NavigationView { + List{ - if(liveUser.playlists.count > 0){ + if liveUser.user?.spotify_linked == false { + Text("Spotify isn't linked, login to the web client to pair") + + Button(action: { + UIApplication.shared.open(URL(string: "https://mixonomer.sarsoo.xyz/")!) + }) { + Text("Go-to Mixonomer Web") + .foregroundColor(.blue) + } + } + else if liveUser.playlists.count > 0 { ForEach(liveUser.playlists.indices, id:\.self) { idx in PlaylistRow(playlist: self.$liveUser.playlists[idx]) } @@ -88,7 +99,11 @@ struct PlaylistList: View { struct PlaylistList_Previews: PreviewProvider { static var previews: some View { - PlaylistList() - .environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false)) + Group { + PlaylistList() + .environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false)) + PlaylistList() + .environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false, user: User(username: "user", email: nil, last_login: "", last_keygen: "", spotify_linked: false, lastfm_username: nil))) + } } }