diff --git a/api/src/main/java/io/kafbat/ui/emitter/ConsumingStats.java b/api/src/main/java/io/kafbat/ui/emitter/ConsumingStats.java index 6287a9903..a2c8d94f3 100644 --- a/api/src/main/java/io/kafbat/ui/emitter/ConsumingStats.java +++ b/api/src/main/java/io/kafbat/ui/emitter/ConsumingStats.java @@ -2,7 +2,7 @@ import io.kafbat.ui.model.TopicMessageConsumingDTO; import io.kafbat.ui.model.TopicMessageEventDTO; -import io.kafbat.ui.model.TopicMessageNextPageCursorDTO; +import io.kafbat.ui.model.TopicMessagePageCursorDTO; import javax.annotation.Nullable; import reactor.core.publisher.FluxSink; @@ -32,9 +32,9 @@ void sendFinishEvent(FluxSink sink, @Nullable Cursor.Track sink.next( new TopicMessageEventDTO() .type(TopicMessageEventDTO.TypeEnum.DONE) - .cursor( + .nextCursor( cursor != null - ? new TopicMessageNextPageCursorDTO().id(cursor.registerCursor()) + ? new TopicMessagePageCursorDTO().id(cursor.registerCursor()) : null ) .consuming(createConsumingStats()) diff --git a/api/src/test/java/io/kafbat/ui/service/MessagesServiceTest.java b/api/src/test/java/io/kafbat/ui/service/MessagesServiceTest.java index 8939b50c3..06dc8e056 100644 --- a/api/src/test/java/io/kafbat/ui/service/MessagesServiceTest.java +++ b/api/src/test/java/io/kafbat/ui/service/MessagesServiceTest.java @@ -131,8 +131,8 @@ void cursorIsRegisteredAfterPollingIsDoneAndCanBeUsedForNextPagePolling(PollingM null, null, pageSize, StringSerde.name(), StringSerde.name()) .doOnNext(evt -> { if (evt.getType() == TopicMessageEventDTO.TypeEnum.DONE) { - assertThat(evt.getCursor()).isNotNull(); - cursorIdCatcher.set(evt.getCursor().getId()); + assertThat(evt.getNextCursor()).isNotNull(); + cursorIdCatcher.set(evt.getNextCursor().getId()); } }) .filter(evt -> evt.getType() == TopicMessageEventDTO.TypeEnum.MESSAGE) @@ -147,7 +147,7 @@ void cursorIsRegisteredAfterPollingIsDoneAndCanBeUsedForNextPagePolling(PollingM Flux remainingMsgs = messagesService.loadMessages(cluster, testTopic, cursorIdCatcher.get()) .doOnNext(evt -> { if (evt.getType() == TopicMessageEventDTO.TypeEnum.DONE) { - assertThat(evt.getCursor()).isNull(); + assertThat(evt.getNextCursor()).isNull(); } }) .filter(evt -> evt.getType() == TopicMessageEventDTO.TypeEnum.MESSAGE) diff --git a/contract/src/main/resources/swagger/kafbat-ui-api.yaml b/contract/src/main/resources/swagger/kafbat-ui-api.yaml index 7ca62831f..53b6fc5ea 100644 --- a/contract/src/main/resources/swagger/kafbat-ui-api.yaml +++ b/contract/src/main/resources/swagger/kafbat-ui-api.yaml @@ -2954,8 +2954,8 @@ components: $ref: "#/components/schemas/TopicMessagePhase" consuming: $ref: "#/components/schemas/TopicMessageConsuming" - cursor: - $ref: "#/components/schemas/TopicMessageNextPageCursor" + nextCursor: + $ref: "#/components/schemas/TopicMessagePageCursor" TopicMessagePhase: type: object @@ -2985,7 +2985,7 @@ components: filterApplyErrors: type: integer - TopicMessageNextPageCursor: + TopicMessagePageCursor: type: object properties: id: diff --git a/frontend/src/lib/hooks/api/topicMessages.tsx b/frontend/src/lib/hooks/api/topicMessages.tsx index adcaed85a..60621df1f 100644 --- a/frontend/src/lib/hooks/api/topicMessages.tsx +++ b/frontend/src/lib/hooks/api/topicMessages.tsx @@ -103,7 +103,6 @@ export const useTopicMessages = ({ } const { nextCursor, setNextCursor } = useMessageFiltersStore.getState(); - const searchParamPage = getPageValue(searchParams); if (currentPage.current < searchParamPage && nextCursor) { requestParams.set(MessagesFilterKeys.cursor, nextCursor); @@ -125,11 +124,7 @@ export const useTopicMessages = ({ }, onmessage(event) { const parsedData: TopicMessageEvent = JSON.parse(event.data); - const { message, consuming, cursor } = parsedData; - - if (useMessageFiltersStore.getState().nextCursor !== cursor?.id) { - setNextCursor(cursor?.id || undefined); - } + const { message, consuming } = parsedData; switch (parsedData.type) { case TopicMessageEventTypeEnum.MESSAGE: @@ -148,6 +143,11 @@ export const useTopicMessages = ({ case TopicMessageEventTypeEnum.CONSUMING: if (consuming) setConsumptionStats(consuming); break; + case TopicMessageEventTypeEnum.DONE: + if (nextCursor !== parsedData.nextCursor?.id) { + setNextCursor(parsedData.nextCursor?.id || undefined); + } + break; default: } },