better handling logout, clearing all of live user, closes #21
This commit is contained in:
parent
ad55f5b787
commit
9e3417f3fa
@ -50,6 +50,11 @@ class LiveUser: ObservableObject {
|
|||||||
try keychain.remove("username")
|
try keychain.remove("username")
|
||||||
try keychain.remove("jwt")
|
try keychain.remove("jwt")
|
||||||
|
|
||||||
|
playlists.removeAll()
|
||||||
|
tags.removeAll()
|
||||||
|
username = ""
|
||||||
|
user = nil
|
||||||
|
|
||||||
UserDefaults.standard.removeObject(forKey: "playlists")
|
UserDefaults.standard.removeObject(forKey: "playlists")
|
||||||
UserDefaults.standard.removeObject(forKey: "tags")
|
UserDefaults.standard.removeObject(forKey: "tags")
|
||||||
|
|
||||||
|
@ -20,8 +20,19 @@ struct PlaylistList: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationView {
|
NavigationView {
|
||||||
|
|
||||||
List{
|
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
|
ForEach(liveUser.playlists.indices, id:\.self) { idx in
|
||||||
PlaylistRow(playlist: self.$liveUser.playlists[idx])
|
PlaylistRow(playlist: self.$liveUser.playlists[idx])
|
||||||
}
|
}
|
||||||
@ -88,7 +99,11 @@ struct PlaylistList: View {
|
|||||||
|
|
||||||
struct PlaylistList_Previews: PreviewProvider {
|
struct PlaylistList_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
PlaylistList()
|
Group {
|
||||||
.environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false))
|
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)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user