adding last spotify refresh, locked to user object
This commit is contained in:
parent
589ca39555
commit
a97a17eea6
@ -22,29 +22,38 @@ class User: Identifiable, Decodable {
|
|||||||
var email: String?
|
var email: String?
|
||||||
var type: UserType
|
var type: UserType
|
||||||
|
|
||||||
|
var locked: Bool
|
||||||
|
|
||||||
var last_login: String
|
var last_login: String
|
||||||
var last_keygen: String
|
var last_keygen: String
|
||||||
|
var last_refreshed: String
|
||||||
|
|
||||||
var spotify_linked: Bool
|
var spotify_linked: Bool
|
||||||
@Published var lastfm_username: String?
|
@Published var lastfm_username: String?
|
||||||
|
|
||||||
//MARK: Initialization
|
//MARK: Initialization
|
||||||
|
|
||||||
init(username: String,
|
init(username: String = "user",
|
||||||
email: String?,
|
email: String? = nil,
|
||||||
type: UserType = .user,
|
type: UserType = .user,
|
||||||
|
|
||||||
last_login: String,
|
locked: Bool = false,
|
||||||
last_keygen: String,
|
|
||||||
spotify_linked: Bool,
|
last_login: String = "",
|
||||||
lastfm_username: String?){
|
last_keygen: String = "",
|
||||||
|
last_refreshed: String = "",
|
||||||
|
spotify_linked: Bool = true,
|
||||||
|
lastfm_username: String? = nil){
|
||||||
|
|
||||||
self.username = username
|
self.username = username
|
||||||
self.email = email
|
self.email = email
|
||||||
self.type = type
|
self.type = type
|
||||||
|
|
||||||
|
self.locked = locked
|
||||||
|
|
||||||
self.last_login = last_login
|
self.last_login = last_login
|
||||||
self.last_keygen = last_keygen
|
self.last_keygen = last_keygen
|
||||||
|
self.last_refreshed = last_refreshed
|
||||||
self.spotify_linked = spotify_linked
|
self.spotify_linked = spotify_linked
|
||||||
self.lastfm_username = lastfm_username
|
self.lastfm_username = lastfm_username
|
||||||
}
|
}
|
||||||
@ -54,8 +63,11 @@ class User: Identifiable, Decodable {
|
|||||||
case email
|
case email
|
||||||
case type
|
case type
|
||||||
|
|
||||||
|
case locked
|
||||||
|
|
||||||
case last_login
|
case last_login
|
||||||
case last_keygen
|
case last_keygen
|
||||||
|
case last_refreshed
|
||||||
|
|
||||||
case spotify_linked
|
case spotify_linked
|
||||||
case lastfm_username
|
case lastfm_username
|
||||||
@ -72,6 +84,7 @@ class User: Identifiable, Decodable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type = try container.decode(UserType.self, forKey: .type)
|
type = try container.decode(UserType.self, forKey: .type)
|
||||||
|
locked = try container.decode(Bool.self, forKey: .locked)
|
||||||
|
|
||||||
last_login = try container.decode(String.self, forKey: .last_login)
|
last_login = try container.decode(String.self, forKey: .last_login)
|
||||||
do{
|
do{
|
||||||
@ -79,6 +92,11 @@ class User: Identifiable, Decodable {
|
|||||||
}catch {
|
}catch {
|
||||||
last_keygen = ""
|
last_keygen = ""
|
||||||
}
|
}
|
||||||
|
do{
|
||||||
|
last_refreshed = try container.decode(String.self, forKey: .last_refreshed)
|
||||||
|
}catch {
|
||||||
|
last_refreshed = ""
|
||||||
|
}
|
||||||
|
|
||||||
spotify_linked = try container.decode(Bool.self, forKey: .spotify_linked)
|
spotify_linked = try container.decode(Bool.self, forKey: .spotify_linked)
|
||||||
do{
|
do{
|
||||||
@ -95,8 +113,11 @@ class User: Identifiable, Decodable {
|
|||||||
try container.encode(self.email, forKey: .email)
|
try container.encode(self.email, forKey: .email)
|
||||||
try container.encode(self.type.rawValue, forKey: .type)
|
try container.encode(self.type.rawValue, forKey: .type)
|
||||||
|
|
||||||
|
try container.encode(self.locked, forKey: .locked)
|
||||||
|
|
||||||
try container.encode(self.last_login, forKey: .last_login)
|
try container.encode(self.last_login, forKey: .last_login)
|
||||||
try container.encode(self.last_keygen, forKey: .last_keygen)
|
try container.encode(self.last_keygen, forKey: .last_keygen)
|
||||||
|
try container.encode(self.last_refreshed, forKey: .last_refreshed)
|
||||||
|
|
||||||
try container.encode(self.spotify_linked, forKey: .spotify_linked)
|
try container.encode(self.spotify_linked, forKey: .spotify_linked)
|
||||||
try container.encode(self.lastfm_username, forKey: .lastfm_username)
|
try container.encode(self.lastfm_username, forKey: .lastfm_username)
|
||||||
|
@ -55,6 +55,13 @@ struct UserView: View {
|
|||||||
Text(user.last_keygen)
|
Text(user.last_keygen)
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HStack {
|
||||||
|
Text("Last Spotify Refresh")
|
||||||
|
Spacer()
|
||||||
|
Text(user.last_refreshed)
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationBarTitle(Text(user.username))
|
.navigationBarTitle(Text(user.username))
|
||||||
@ -63,6 +70,6 @@ struct UserView: View {
|
|||||||
|
|
||||||
struct UserView_Previews: PreviewProvider {
|
struct UserView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
UserView(user: .constant(User(username: "", email: "", last_login: "", last_keygen: "", spotify_linked: true, lastfm_username: nil)))
|
UserView(user: .constant(User()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ struct PlaylistList_Previews: PreviewProvider {
|
|||||||
PlaylistList()
|
PlaylistList()
|
||||||
.environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false))
|
.environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false))
|
||||||
PlaylistList()
|
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)))
|
.environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false, user: User()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ struct PlaylistView_Previews: PreviewProvider {
|
|||||||
lastfm_stat_artist_percent: 80
|
lastfm_stat_artist_percent: 80
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
.environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false, user: User(username: "", email: "", last_login: "", last_keygen: "", spotify_linked: true, lastfm_username: "last.fm")))
|
.environmentObject(LiveUser(playlists: [], tags: [], username: "user", loggedIn: false, user: User()))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,22 @@ struct SettingsList: View {
|
|||||||
Text("Log out")
|
Text("Log out")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Section(header: Text("Config")) {
|
||||||
|
if let spotify_linked = self.liveUser.user?.spotify_linked {
|
||||||
|
Toggle(isOn: .constant(spotify_linked)) {
|
||||||
|
Text("Spotify Link")
|
||||||
|
}
|
||||||
|
.disabled(true)
|
||||||
|
}
|
||||||
|
// HStack {
|
||||||
|
// Text("Last.fm Username")
|
||||||
|
// Spacer()
|
||||||
|
//
|
||||||
|
// Text(self.$liveUser.user.lastfm_username ?? .constant(""))
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
deleteAlertShowing = true
|
deleteAlertShowing = true
|
||||||
|
Loading…
Reference in New Issue
Block a user