New account selection menu

This commit is contained in:
Arkadiusz Fal
2022-12-11 23:15:56 +01:00
parent 4c143f6d88
commit d02bb23e57
26 changed files with 312 additions and 128 deletions

View File

@@ -134,8 +134,6 @@ struct YatteeApp: App {
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDWebImageManager.defaultImageCache = PINCache(name: "stream.yattee.app")
migrateAccounts()
if !Defaults[.lastAccountIsPublic] {
AccountsModel.shared.configureAccount()
}
@@ -182,28 +180,4 @@ struct YatteeApp: App {
URLBookmarkModel.shared.refreshAll()
}
func migrateAccounts() {
Defaults[.accounts].forEach { account in
if !account.username.isEmpty || !(account.password?.isEmpty ?? true) || !(account.name?.isEmpty ?? true) {
print("Account needs migration: \(account.description)")
if account.app == .invidious {
if let name = account.name, !name.isEmpty {
AccountsModel.setCredentials(account, username: name, password: "")
}
if !account.username.isEmpty {
AccountsModel.setToken(account, account.username)
}
} else if account.app == .piped,
!account.username.isEmpty,
let password = account.password,
!password.isEmpty
{
AccountsModel.setCredentials(account, username: account.username, password: password)
}
AccountsModel.removeDefaultsCredentials(account)
}
}
}
}