Skip to content

Commit f5eec43

Browse files
Update conditional to hopefully work with multiple pages
1 parent 2a85c91 commit f5eec43

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ class FixRestChannel {
6969
final Instant startAt, final boolean reverse) {
7070

7171
final ToLongFunction<List<T>> updateLast = { list ->
72-
list.isEmpty() ? startAt : keyExtractor.applyAsInstant(list.get(list.size() - 1)).getEpochSecond()
72+
list.isEmpty() ? startAt.getEpochSecond() : keyExtractor.applyAsInstant(list.get(list.size() - 1)).getEpochSecond()
7373
}
7474

7575
final ToIntFunction<List<T>> updateLast_ns = { list ->
76-
list.isEmpty() ? startAt : keyExtractor.applyAsInstant(list.get(list.size() - 1)).getNano()
76+
list.isEmpty() ? startAt.getNano() : keyExtractor.applyAsInstant(list.get(list.size() - 1)).getNano()
7777
}
7878

7979
final Comparator<T> comparator = comparingInstant(keyExtractor);
@@ -91,7 +91,8 @@ class FixRestChannel {
9191
private static Flux<ListThreadsData> listThreads(Function<Map<String, Object>, Mono<ListThreadsData>> doRequest) {
9292
ToInstantFunction<ListThreadsData> getLastThreadId = { response ->
9393
List<ChannelData> threads = response.threads();
94-
return threads.isEmpty() ? Instant.ofEpochSecond(0) : Instant.parse(threads.get(threads.size() - 1).threadMetadata().get().archiveTimestamp().replace('+00:00', "Z"));
94+
95+
return (!response.hasMore() || threads.isEmpty()) ? Instant.ofEpochSecond(0) : Instant.parse(threads.get(threads.size() - 1).threadMetadata().get().archiveTimestamp().replace('+00:00', "Z"));
9596
}
9697
final InstantFunction<Flux<ListThreadsData>> nextPage = { long s, long n ->
9798
final Map<String, Object> parameters = new HashMap<>(2);

0 commit comments

Comments
 (0)