Skip to content

Commit f708091

Browse files
authored
Fix double topic message display bug (#1870)
* fix double topic message display bug * fix variable name
1 parent 85f0956 commit f708091

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

kafka-ui-react-app/src/components/Topics/Topic/Details/Messages/MessagesTable.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,11 @@ const MessagesTable: React.FC = () => {
3939
return { offset: 0, partition: parseInt(partition, 10) };
4040
});
4141

42+
const seekDirection = searchParams.get('seekDirection');
43+
const isBackward = seekDirection === SeekDirection.BACKWARD;
44+
4245
const messageUniqs = map(groupBy(messages, 'partition'), (v) =>
43-
searchParams.get('seekDirection') === SeekDirection.BACKWARD
44-
? minBy(v, 'offset')
45-
: maxBy(v, 'offset')
46+
isBackward ? minBy(v, 'offset') : maxBy(v, 'offset')
4647
).map((message) => ({
4748
offset: message?.offset || 0,
4849
partition: message?.partition || 0,
@@ -54,7 +55,11 @@ const MessagesTable: React.FC = () => {
5455
(v) => maxBy(v, 'offset')
5556
)
5657
)
57-
.map(({ offset, partition }) => `${partition}::${offset}`)
58+
.map(({ offset, partition }) => {
59+
const offsetQuery = isBackward ? offset : offset + 1;
60+
61+
return `${partition}::${offsetQuery}`;
62+
})
5863
.join(',');
5964

6065
searchParams.set('seekTo', nextSeekTo);

0 commit comments

Comments
 (0)