mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-22 23:26:37 +00:00
Various optimizations to speed things up
This commit is contained in:
parent
536f0977a0
commit
24504e3bc2
16 changed files with 30 additions and 18 deletions
|
@ -116,7 +116,7 @@ struct IceCubesApp: App {
|
|||
}
|
||||
}
|
||||
if proxy.frame(in: .global).width > (.maxColumnWidth + .secondaryColumnWidth),
|
||||
currentAccount.account?.id != nil
|
||||
appAccountsManager.currentClient.isAuth
|
||||
{
|
||||
Divider().edgesIgnoringSafeArea(.all)
|
||||
NotificationsTab(popToRootTab: $popToRootTab, lockedType: nil)
|
||||
|
|
|
@ -30,7 +30,7 @@ struct MessagesTab: View {
|
|||
}
|
||||
}
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.id(currentAccount.account?.id)
|
||||
.id(client.id)
|
||||
}
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
if popToRootTab == .messages {
|
||||
|
|
|
@ -9,6 +9,7 @@ import Timeline
|
|||
|
||||
struct NotificationsTab: View {
|
||||
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
||||
@Environment(\.scenePhase) private var scenePhase
|
||||
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var client: Client
|
||||
|
@ -38,7 +39,7 @@ struct NotificationsTab: View {
|
|||
}
|
||||
}
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.id(currentAccount.account?.id)
|
||||
.id(client.id)
|
||||
}
|
||||
.onAppear {
|
||||
routerPath.client = client
|
||||
|
@ -52,6 +53,17 @@ struct NotificationsTab: View {
|
|||
routerPath.path = []
|
||||
}
|
||||
}
|
||||
.onChange(of: scenePhase, perform: { scenePhase in
|
||||
switch scenePhase {
|
||||
case .active:
|
||||
if isSecondaryColumn {
|
||||
watcher.unreadNotificationsCount = 0
|
||||
userPreferences.pushNotificationsCount = 0
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
})
|
||||
.onChange(of: currentAccount.account?.id) { _ in
|
||||
routerPath.path = []
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import Shimmer
|
|||
import SwiftUI
|
||||
|
||||
struct ProfileTab: View {
|
||||
@EnvironmentObject private var appAccount: AppAccountsManager
|
||||
@EnvironmentObject private var theme: Theme
|
||||
@EnvironmentObject private var client: Client
|
||||
@EnvironmentObject private var currentAccount: CurrentAccount
|
||||
|
@ -22,11 +23,10 @@ struct ProfileTab: View {
|
|||
.withAppRouter()
|
||||
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.id(currentAccount.account?.id)
|
||||
.id(client.id)
|
||||
} else {
|
||||
AccountDetailView(account: .placeholder())
|
||||
.redacted(reason: .placeholder)
|
||||
.shimmering()
|
||||
}
|
||||
}
|
||||
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
||||
|
|
|
@ -37,7 +37,7 @@ struct TimelineTab: View {
|
|||
toolbarView
|
||||
}
|
||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
||||
.id(currentAccount.account?.id)
|
||||
.id(client.id)
|
||||
}
|
||||
.onAppear {
|
||||
routerPath.client = client
|
||||
|
@ -144,7 +144,7 @@ struct TimelineTab: View {
|
|||
if UIDevice.current.userInterfaceIdiom != .pad {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
AppAccountsSelectorView(routerPath: routerPath)
|
||||
.id(currentAccount.account?.id)
|
||||
.id(client.id)
|
||||
}
|
||||
}
|
||||
statusEditorToolbarItem(routerPath: routerPath,
|
||||
|
|
|
@ -143,7 +143,6 @@ public struct AccountDetailView: View {
|
|||
scrollViewProxy: proxy,
|
||||
scrollOffset: $scrollOffset)
|
||||
.redacted(reason: .placeholder)
|
||||
.shimmering()
|
||||
case let .data(account):
|
||||
AccountDetailHeaderView(viewModel: viewModel,
|
||||
account: account,
|
||||
|
|
|
@ -55,7 +55,7 @@ public struct AppAccountsSelectorView: View {
|
|||
@ViewBuilder
|
||||
private var labelView: some View {
|
||||
Group {
|
||||
if let avatar = currentAccount.account?.avatar {
|
||||
if let avatar = currentAccount.account?.avatar, !currentAccount.isLoadingAccount {
|
||||
AvatarView(url: avatar, size: avatarSize)
|
||||
} else {
|
||||
ProgressView()
|
||||
|
|
|
@ -99,7 +99,6 @@ public struct ConversationDetailView: View {
|
|||
ForEach(Status.placeholders()) { message in
|
||||
ConversationMessageView(message: message, conversation: viewModel.conversation)
|
||||
.redacted(reason: .placeholder)
|
||||
.shimmering()
|
||||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,7 +135,6 @@ struct ConversationMessageView: View {
|
|||
RoundedRectangle(cornerRadius: 8)
|
||||
.fill(Color.gray)
|
||||
.frame(height: 200)
|
||||
.shimmering()
|
||||
}
|
||||
}
|
||||
.frame(height: 200)
|
||||
|
|
|
@ -32,7 +32,6 @@ public struct ConversationsListView: View {
|
|||
ConversationsListRow(conversation: conversation, viewModel: viewModel)
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
.redacted(reason: .placeholder)
|
||||
.shimmering()
|
||||
} else {
|
||||
ConversationsListRow(conversation: conversation, viewModel: viewModel)
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
|
|
|
@ -9,6 +9,7 @@ public class CurrentAccount: ObservableObject {
|
|||
@Published public private(set) var tags: [Tag] = []
|
||||
@Published public private(set) var followRequests: [Account] = []
|
||||
@Published public private(set) var isUpdating: Bool = false
|
||||
@Published public private(set) var isLoadingAccount: Bool = false
|
||||
|
||||
private var client: Client?
|
||||
|
||||
|
@ -26,8 +27,8 @@ public class CurrentAccount: ObservableObject {
|
|||
|
||||
private func fetchUserData() async {
|
||||
await withTaskGroup(of: Void.self) { group in
|
||||
group.addTask { await self.fetchConnections() }
|
||||
group.addTask { await self.fetchCurrentAccount() }
|
||||
group.addTask { await self.fetchConnections() }
|
||||
group.addTask { await self.fetchLists() }
|
||||
group.addTask { await self.fetchFollowedTags() }
|
||||
group.addTask { await self.fetchFollowerRequests() }
|
||||
|
@ -47,7 +48,9 @@ public class CurrentAccount: ObservableObject {
|
|||
account = nil
|
||||
return
|
||||
}
|
||||
isLoadingAccount = true
|
||||
account = try? await client.get(endpoint: Accounts.verifyCredentials)
|
||||
isLoadingAccount = false
|
||||
}
|
||||
|
||||
public func fetchLists() async {
|
||||
|
|
|
@ -84,7 +84,6 @@ public struct ExploreView: View {
|
|||
StatusRowView(viewModel: .init(status: status, isCompact: false))
|
||||
.padding(.vertical, 8)
|
||||
.redacted(reason: .placeholder)
|
||||
.shimmering()
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import Foundation
|
|||
import Models
|
||||
import SwiftUI
|
||||
|
||||
public class Client: ObservableObject, Equatable {
|
||||
public class Client: ObservableObject, Equatable, Identifiable {
|
||||
public static func == (lhs: Client, rhs: Client) -> Bool {
|
||||
lhs.isAuth == rhs.isAuth &&
|
||||
lhs.server == rhs.server &&
|
||||
|
@ -18,6 +18,10 @@ public class Client: ObservableObject, Equatable {
|
|||
case invalidRedirectURL
|
||||
}
|
||||
|
||||
public var id: String {
|
||||
"\(isAuth)\(server)\(oauthToken?.accessToken ?? "")"
|
||||
}
|
||||
|
||||
public var server: String
|
||||
public let version: Version
|
||||
public private(set) var connections: Set<String>
|
||||
|
|
|
@ -87,7 +87,7 @@ public struct NotificationsListView: View {
|
|||
bottom: 12,
|
||||
trailing: .layoutPadding))
|
||||
.listRowBackground(theme.primaryBackgroundColor)
|
||||
.shimmering()
|
||||
.redacted(reason: .placeholder)
|
||||
}
|
||||
|
||||
case let .display(notifications, nextPageState):
|
||||
|
|
|
@ -35,7 +35,6 @@ public struct StatusDetailView: View {
|
|||
StatusRowView(viewModel: .init(status: status, isCompact: false))
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
.redacted(reason: .placeholder)
|
||||
.shimmering()
|
||||
Divider()
|
||||
.padding(.vertical, .dividerPadding)
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ public struct StatusesListView<Fetcher>: View where Fetcher: StatusesFetcher {
|
|||
StatusRowView(viewModel: .init(status: status, isCompact: false))
|
||||
.redacted(reason: .placeholder)
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
.shimmering()
|
||||
Divider()
|
||||
.padding(.vertical, .dividerPadding)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue