mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +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)
|
makeTagsListView(tags: tags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.background(theme.primaryBackgroundColor)
|
|
||||||
}
|
}
|
||||||
|
.background(theme.primaryBackgroundColor)
|
||||||
}
|
}
|
||||||
.task {
|
.onAppear {
|
||||||
guard reasons != .placeholder else { return }
|
Task {
|
||||||
isCurrentUser = currentAccount.account?.id == viewModel.accountId
|
guard reasons != .placeholder else { return }
|
||||||
viewModel.isCurrentUser = isCurrentUser
|
isCurrentUser = currentAccount.account?.id == viewModel.accountId
|
||||||
viewModel.client = client
|
viewModel.isCurrentUser = isCurrentUser
|
||||||
await viewModel.fetchAccount()
|
viewModel.client = client
|
||||||
if viewModel.statuses.isEmpty {
|
await viewModel.fetchAccount()
|
||||||
await viewModel.fetchStatuses()
|
if viewModel.statuses.isEmpty {
|
||||||
|
await viewModel.fetchStatuses()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.refreshable {
|
.refreshable {
|
||||||
|
|
|
@ -126,7 +126,8 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: .loadingNextPage))
|
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: .loadingNextPage))
|
||||||
let newStatuses: [Status] = try await client.get(endpoint: Accounts.statuses(id: accountId, sinceId: lastId, tag: nil))
|
let newStatuses: [Status] = try await client.get(endpoint: Accounts.statuses(id: accountId, sinceId: lastId, tag: nil))
|
||||||
statuses.append(contentsOf: newStatuses)
|
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:
|
case .favourites:
|
||||||
guard let nextPageId = favouritesNextPage?.maxId else { return }
|
guard let nextPageId = favouritesNextPage?.maxId else { return }
|
||||||
let newFavourites: [Status]
|
let newFavourites: [Status]
|
||||||
|
@ -162,7 +163,7 @@ class AccountDetailViewModel: ObservableObject, StatusesFetcher {
|
||||||
private func reloadTabState() {
|
private func reloadTabState() {
|
||||||
switch selectedTab {
|
switch selectedTab {
|
||||||
case .statuses:
|
case .statuses:
|
||||||
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: .hasNextPage))
|
tabState = .statuses(statusesState: .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage))
|
||||||
case .favourites:
|
case .favourites:
|
||||||
tabState = .statuses(statusesState: .display(statuses: favourites,
|
tabState = .statuses(statusesState: .display(statuses: favourites,
|
||||||
nextPageState: favouritesNextPage != nil ? .hasNextPage : .none))
|
nextPageState: favouritesNextPage != nil ? .hasNextPage : .none))
|
||||||
|
|
|
@ -116,6 +116,8 @@ public struct ExploreView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(theme.primaryBackgroundColor)
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
.navigationTitle("Suggested Users")
|
.navigationTitle("Suggested Users")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
@ -143,6 +145,8 @@ public struct ExploreView: View {
|
||||||
.padding(.vertical, 4)
|
.padding(.vertical, 4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(theme.primaryBackgroundColor)
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
.navigationTitle("Trending Tags")
|
.navigationTitle("Trending Tags")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
@ -171,6 +175,8 @@ public struct ExploreView: View {
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(theme.primaryBackgroundColor)
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
.navigationTitle("Trending Posts")
|
.navigationTitle("Trending Posts")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
@ -198,6 +204,8 @@ public struct ExploreView: View {
|
||||||
.padding(.vertical, 8)
|
.padding(.vertical, 8)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(theme.primaryBackgroundColor)
|
||||||
.listStyle(.plain)
|
.listStyle(.plain)
|
||||||
.navigationTitle("Trending Links")
|
.navigationTitle("Trending Links")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
|
|
|
@ -58,6 +58,7 @@ public struct StatusDetailView: View {
|
||||||
.padding(.horizontal, DS.Constants.layoutPadding)
|
.padding(.horizontal, DS.Constants.layoutPadding)
|
||||||
.padding(.top, DS.Constants.layoutPadding)
|
.padding(.top, DS.Constants.layoutPadding)
|
||||||
}
|
}
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
.background(theme.primaryBackgroundColor)
|
.background(theme.primaryBackgroundColor)
|
||||||
.task {
|
.task {
|
||||||
guard !isLoaded else { return }
|
guard !isLoaded else { return }
|
||||||
|
|
Loading…
Reference in a new issue