Skip to content

Commit 76b012e

Browse files
authored
fix pagination issue when refreshing mastodon feed (#532)
1 parent 854afb3 commit 76b012e

File tree

4 files changed

+449
-16
lines changed

4 files changed

+449
-16
lines changed

CriticalMapsKit/Sources/MastodonFeedFeature/TootFeedFeature.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ public struct TootFeedFeature: Sendable {
5858
case .refresh:
5959
state.isRefreshing = true
6060
return .send(.fetchData)
61-
61+
6262
case .fetchData:
6363
state.isLoading = true
64-
return .run { [lastId = state.toots.last?.id] send in
64+
return .run { send in
6565
await send(
6666
.fetchDataResponse(
67-
Result { try await tootService.getToots(lastId) }
67+
Result { try await tootService.getToots(nil) }
6868
)
6969
)
7070
}
@@ -88,8 +88,7 @@ public struct TootFeedFeature: Sendable {
8888
state.isLoading = false
8989
state.error = .init(
9090
title: L10n.ErrorState.title,
91-
body: L10n.ErrorState.message,
92-
error: .init(error: error)
91+
body: L10n.ErrorState.message
9392
)
9493
return .none
9594

@@ -121,8 +120,7 @@ public struct TootFeedFeature: Sendable {
121120
state.hasMore = false
122121
state.error = .init(
123122
title: L10n.ErrorState.title,
124-
body: L10n.ErrorState.message,
125-
error: .init(error: error)
123+
body: L10n.ErrorState.message
126124
)
127125
return .none
128126

CriticalMapsKit/Sources/MastodonFeedFeature/TootsListView.swift

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ public struct TootsListView: View {
2929

3030
private struct LoadingView: View {
3131
var body: some View {
32-
VStack {
33-
Spacer()
34-
ProgressView {
35-
Text("Loading")
36-
.foregroundColor(.textPrimary)
37-
.font(.bodyOne)
38-
}
39-
Spacer()
32+
ProgressView {
33+
Text(L10n.Social.Feed.loading)
34+
.foregroundColor(.textPrimary)
35+
.font(.bodyOne)
4036
}
37+
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .center)
4138
}
4239
}
4340

CriticalMapsKit/Sources/Styleguide/ErrorStateView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public struct ErrorState: Equatable, Sendable {
2121

2222
public init(
2323
error: Error,
24-
file: StaticString = #fileID,
24+
file: StaticString = #filePath,
2525
line: UInt = #line
2626
) {
2727
var string = ""

0 commit comments

Comments
 (0)