Skip to content

Commit 8b580f5

Browse files
committed
FE: Rename cursor to nextCursor in topic message response (kafbat#550)
1 parent 67e05a9 commit 8b580f5

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

api/src/main/java/io/kafbat/ui/emitter/ConsumingStats.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import io.kafbat.ui.model.TopicMessageConsumingDTO;
44
import io.kafbat.ui.model.TopicMessageEventDTO;
5-
import io.kafbat.ui.model.TopicMessageNextPageCursorDTO;
5+
import io.kafbat.ui.model.TopicMessagePageCursorDTO;
66
import javax.annotation.Nullable;
77
import reactor.core.publisher.FluxSink;
88

@@ -32,9 +32,9 @@ void sendFinishEvent(FluxSink<TopicMessageEventDTO> sink, @Nullable Cursor.Track
3232
sink.next(
3333
new TopicMessageEventDTO()
3434
.type(TopicMessageEventDTO.TypeEnum.DONE)
35-
.cursor(
35+
.nextCursor(
3636
cursor != null
37-
? new TopicMessageNextPageCursorDTO().id(cursor.registerCursor())
37+
? new TopicMessagePageCursorDTO().id(cursor.registerCursor())
3838
: null
3939
)
4040
.consuming(createConsumingStats())

api/src/test/java/io/kafbat/ui/service/MessagesServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ void cursorIsRegisteredAfterPollingIsDoneAndCanBeUsedForNextPagePolling(PollingM
131131
null, null, pageSize, StringSerde.name(), StringSerde.name())
132132
.doOnNext(evt -> {
133133
if (evt.getType() == TopicMessageEventDTO.TypeEnum.DONE) {
134-
assertThat(evt.getCursor()).isNotNull();
135-
cursorIdCatcher.set(evt.getCursor().getId());
134+
assertThat(evt.getNextCursor()).isNotNull();
135+
cursorIdCatcher.set(evt.getNextCursor().getId());
136136
}
137137
})
138138
.filter(evt -> evt.getType() == TopicMessageEventDTO.TypeEnum.MESSAGE)
@@ -147,7 +147,7 @@ void cursorIsRegisteredAfterPollingIsDoneAndCanBeUsedForNextPagePolling(PollingM
147147
Flux<String> remainingMsgs = messagesService.loadMessages(cluster, testTopic, cursorIdCatcher.get())
148148
.doOnNext(evt -> {
149149
if (evt.getType() == TopicMessageEventDTO.TypeEnum.DONE) {
150-
assertThat(evt.getCursor()).isNull();
150+
assertThat(evt.getNextCursor()).isNull();
151151
}
152152
})
153153
.filter(evt -> evt.getType() == TopicMessageEventDTO.TypeEnum.MESSAGE)

contract/src/main/resources/swagger/kafbat-ui-api.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,8 +2954,8 @@ components:
29542954
$ref: "#/components/schemas/TopicMessagePhase"
29552955
consuming:
29562956
$ref: "#/components/schemas/TopicMessageConsuming"
2957-
cursor:
2958-
$ref: "#/components/schemas/TopicMessageNextPageCursor"
2957+
nextCursor:
2958+
$ref: "#/components/schemas/TopicMessagePageCursor"
29592959

29602960
TopicMessagePhase:
29612961
type: object
@@ -2985,7 +2985,7 @@ components:
29852985
filterApplyErrors:
29862986
type: integer
29872987

2988-
TopicMessageNextPageCursor:
2988+
TopicMessagePageCursor:
29892989
type: object
29902990
properties:
29912991
id:

frontend/src/lib/hooks/api/topicMessages.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ export const useTopicMessages = ({
103103
}
104104
const { nextCursor, setNextCursor } = useMessageFiltersStore.getState();
105105

106-
107106
const searchParamPage = getPageValue(searchParams);
108107
if (currentPage.current < searchParamPage && nextCursor) {
109108
requestParams.set(MessagesFilterKeys.cursor, nextCursor);
@@ -125,11 +124,7 @@ export const useTopicMessages = ({
125124
},
126125
onmessage(event) {
127126
const parsedData: TopicMessageEvent = JSON.parse(event.data);
128-
const { message, consuming, cursor } = parsedData;
129-
130-
if (useMessageFiltersStore.getState().nextCursor !== cursor?.id) {
131-
setNextCursor(cursor?.id || undefined);
132-
}
127+
const { message, consuming } = parsedData;
133128

134129
switch (parsedData.type) {
135130
case TopicMessageEventTypeEnum.MESSAGE:
@@ -148,6 +143,11 @@ export const useTopicMessages = ({
148143
case TopicMessageEventTypeEnum.CONSUMING:
149144
if (consuming) setConsumptionStats(consuming);
150145
break;
146+
case TopicMessageEventTypeEnum.DONE:
147+
if (nextCursor !== parsedData.nextCursor?.id) {
148+
setNextCursor(parsedData.nextCursor?.id || undefined);
149+
}
150+
break;
151151
default:
152152
}
153153
},

0 commit comments

Comments
 (0)