mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-27 09:30:37 +00:00
Handle correct pagination on profile for statuses
This commit is contained in:
parent
d00c3e533e
commit
1449719af0
4 changed files with 23 additions and 11 deletions
|
@ -64,17 +64,19 @@ public struct AccountDetailView: View {
|
|||
makeTagsListView(tags: tags)
|
||||
}
|
||||
}
|
||||
.background(theme.primaryBackgroundColor)
|
||||
}
|
||||
.background(theme.primaryBackgroundColor)
|
||||
}
|
||||
.task {
|
||||
guard reasons != .placeholder else { return }
|
||||
isCurrentUser = currentAccount.account?.id == viewModel.accountId
|
||||
viewModel.isCurrentUser = isCurrentUser
|
||||
viewModel.client = client
|
||||
await viewModel.fetchAccount()
|
||||
if viewModel.statuses.isEmpty {
|
||||
await viewModel.fetchStatuses()
|
||||
.onAppear {
|
||||
Task {
|
||||
guard reasons != .placeholder else { return }
|
||||
isCurrentUser = currentAccount.account?.id == viewModel.accountId
|
||||
viewModel.isCurrentUser = isCurrentUser
|
||||
viewModel.client = client
|
||||
await viewModel.fetchAccount()
|
||||
if viewModel.statuses.isEmpty {
|
||||
await viewModel.fetchStatuses()
|
||||
}
|
||||
}
|
||||
}
|
||||
.refreshable {
|
||||
|
|
|
@ -126,7 +126,8 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: .loadingNextPage))
|
||||
let newStatuses: [Status] = try await client.get(endpoint: Accounts.statuses(id: accountId, sinceId: lastId, tag: nil))
|
||||
statuses.append(contentsOf: newStatuses)
|
||||
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: .hasNextPage))
|
||||
tabState = .statuses(statusesState: .display(statuses: statuses,
|
||||
nextPageState: newStatuses.count < 20 ? .none : .hasNextPage))
|
||||
case .favourites:
|
||||
guard let nextPageId = favouritesNextPage?.maxId else { return }
|
||||
let newFavourites: [Status]
|
||||
|
@ -162,7 +163,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
|||
private func reloadTabState() {
|
||||
switch selectedTab {
|
||||
case .statuses:
|
||||
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: .hasNextPage))
|
||||
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage))
|
||||
case .favourites:
|
||||
tabState = .statuses(statusesState: .display(statuses: favourites,
|
||||
nextPageState: favouritesNextPage != nil ? .hasNextPage : .none))
|
||||
|
|
|
@ -116,6 +116,8 @@ public struct ExploreView: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("Suggested Users")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
@ -143,6 +145,8 @@ public struct ExploreView: View {
|
|||
.padding(.vertical, 4)
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("Trending Tags")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
@ -171,6 +175,8 @@ public struct ExploreView: View {
|
|||
.padding(.vertical, 8)
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("Trending Posts")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
@ -198,6 +204,8 @@ public struct ExploreView: View {
|
|||
.padding(.vertical, 8)
|
||||
}
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.listStyle(.plain)
|
||||
.navigationTitle("Trending Links")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
|
|
@ -58,6 +58,7 @@ public struct StatusDetailView: View {
|
|||
.padding(.horizontal, DS.Constants.layoutPadding)
|
||||
.padding(.top, DS.Constants.layoutPadding)
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
.background(theme.primaryBackgroundColor)
|
||||
.task {
|
||||
guard !isLoaded else { return }
|
||||
|
|
Loading…
Reference in a new issue