Handle correct pagination on profile for statuses

This commit is contained in:
Thomas Ricouard 2022-12-29 11:32:53 +01:00
parent d00c3e533e
commit 1449719af0
4 changed files with 23 additions and 11 deletions

View file

@ -64,10 +64,11 @@ public struct AccountDetailView: View {
makeTagsListView(tags: tags)
}
}
}
.background(theme.primaryBackgroundColor)
}
}
.task {
.onAppear {
Task {
guard reasons != .placeholder else { return }
isCurrentUser = currentAccount.account?.id == viewModel.accountId
viewModel.isCurrentUser = isCurrentUser
@ -77,6 +78,7 @@ public struct AccountDetailView: View {
await viewModel.fetchStatuses()
}
}
}
.refreshable {
Task {
await viewModel.fetchAccount()

View file

@ -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))

View file

@ -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)

View file

@ -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 }