mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-22 22:08:07 +00:00
Fix notifications tab + prepare multi account
This commit is contained in:
parent
2b733e6b10
commit
d393c4b90f
5 changed files with 11 additions and 15 deletions
|
@ -38,9 +38,9 @@ struct IceCubesApp: App {
|
|||
tab.makeContentView(popToRootTab: $popToRootTab)
|
||||
.tabItem {
|
||||
tab.label
|
||||
.badge(tab == .notifications ? watcher.unreadNotificationsCount : 0)
|
||||
}
|
||||
.tag(tab)
|
||||
.badge(tab == .notifications ? watcher.unreadNotificationsCount : 0)
|
||||
}
|
||||
}
|
||||
.tint(theme.tintColor)
|
||||
|
|
|
@ -9,12 +9,12 @@ import DesignSystem
|
|||
struct SettingsTabs: View {
|
||||
@Environment(\.openURL) private var openURL
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
@EnvironmentObject private var currentInstance: CurrentInstance
|
||||
@EnvironmentObject private var appAccountsManager: AppAccountsManager
|
||||
@EnvironmentObject private var theme: Theme
|
||||
|
||||
@State private var signInInProgress = false
|
||||
@State private var accountData: Account?
|
||||
@State private var signInServer = IceCubesApp.defaultServer
|
||||
|
||||
var body: some View {
|
||||
|
@ -36,7 +36,7 @@ struct SettingsTabs: View {
|
|||
.task {
|
||||
if appAccountsManager.currentAccount.oauthToken != nil {
|
||||
signInInProgress = true
|
||||
await refreshAccountInfo()
|
||||
await currentAccount.fetchCurrentAccount()
|
||||
await currentInstance.fetchCurrentInstance()
|
||||
signInInProgress = false
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ struct SettingsTabs: View {
|
|||
|
||||
private var accountSection: some View {
|
||||
Section("Account") {
|
||||
if let accountData {
|
||||
if let accountData = currentAccount.account {
|
||||
VStack(alignment: .leading) {
|
||||
Text(appAccountsManager.currentAccount.server)
|
||||
.font(.headline)
|
||||
|
@ -133,7 +133,6 @@ struct SettingsTabs: View {
|
|||
|
||||
private var signOutButton: some View {
|
||||
Button {
|
||||
accountData = nil
|
||||
appAccountsManager.delete(account: appAccountsManager.currentAccount)
|
||||
} label: {
|
||||
Text("Sign out").foregroundColor(.red)
|
||||
|
@ -155,15 +154,11 @@ struct SettingsTabs: View {
|
|||
do {
|
||||
let oauthToken = try await client.continueOauthFlow(url: url)
|
||||
appAccountsManager.add(account: AppAccount(server: client.server, oauthToken: oauthToken))
|
||||
await refreshAccountInfo()
|
||||
await currentAccount.fetchCurrentAccount()
|
||||
await currentInstance.fetchCurrentInstance()
|
||||
signInInProgress = false
|
||||
} catch {
|
||||
signInInProgress = false
|
||||
}
|
||||
}
|
||||
|
||||
private func refreshAccountInfo() async {
|
||||
accountData = try? await client.get(endpoint: Accounts.verifyCredentials)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,7 @@ struct TimelineTab: View {
|
|||
}
|
||||
.onAppear {
|
||||
routeurPath.client = client
|
||||
if !client.isAuth {
|
||||
timeline = .pub
|
||||
}
|
||||
timeline = client.isAuth ? .home : .pub
|
||||
}
|
||||
.environmentObject(routeurPath)
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
|
|
|
@ -20,7 +20,10 @@ public class CurrentAccount: ObservableObject {
|
|||
}
|
||||
|
||||
public func fetchCurrentAccount() async {
|
||||
guard let client = client, client.isAuth else { return }
|
||||
guard let client = client, client.isAuth else {
|
||||
account = nil
|
||||
return
|
||||
}
|
||||
Task {
|
||||
account = try? await client.get(endpoint: Accounts.verifyCredentials)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public struct TimelineView: View {
|
|||
}
|
||||
.padding(.top, DS.Constants.layoutPadding)
|
||||
}
|
||||
if viewModel.timeline == .home {
|
||||
if viewModel.pendingStatusesEnabled {
|
||||
makePendingNewPostsView(proxy: proxy)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue