mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
Fix setting account
This commit is contained in:
parent
78a0291e5d
commit
d061664570
@ -4,6 +4,7 @@ import Foundation
|
||||
struct Instance: Defaults.Serializable, Hashable, Identifiable {
|
||||
struct Account: Defaults.Serializable, Hashable, Identifiable {
|
||||
static var bridge = AccountsBridge()
|
||||
static var empty = Account(instanceID: UUID(), name: "Signed Out", url: "", sid: "")
|
||||
|
||||
let id: UUID
|
||||
let instanceID: UUID
|
||||
@ -36,6 +37,10 @@ struct Instance: Defaults.Serializable, Hashable, Identifiable {
|
||||
(name != nil && name!.isEmpty) ? "Unnamed (\(anonymizedSID))" : name!
|
||||
}
|
||||
|
||||
var isEmpty: Bool {
|
||||
self == Account.empty
|
||||
}
|
||||
|
||||
func hash(into hasher: inout Hasher) {
|
||||
hasher.combine(sid)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import SwiftyJSON
|
||||
final class InvidiousAPI: Service, ObservableObject {
|
||||
static let basePath = "/api/v1"
|
||||
|
||||
@Published var account: Instance.Account!
|
||||
@Published var account: Instance.Account! = .empty
|
||||
|
||||
@Published var validInstance = true
|
||||
@Published var signedIn = true
|
||||
|
@ -40,7 +40,7 @@ struct PearvidiousApp: App {
|
||||
search.api = api
|
||||
subscriptions.api = api
|
||||
|
||||
if let account = instances.defaultAccount, api.account.isNil {
|
||||
if let account = instances.defaultAccount, api.account.isEmpty {
|
||||
api.setAccount(account)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user