ソースを参照

Fix double topic message display bug (#1870)

* fix double topic message display bug

* fix variable name
Arsen Simonyan 3 年 前
コミット
f70809128b

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

@@ -39,10 +39,11 @@ const MessagesTable: React.FC = () => {
         return { offset: 0, partition: parseInt(partition, 10) };
       });
 
+      const seekDirection = searchParams.get('seekDirection');
+      const isBackward = seekDirection === SeekDirection.BACKWARD;
+
       const messageUniqs = map(groupBy(messages, 'partition'), (v) =>
-        searchParams.get('seekDirection') === SeekDirection.BACKWARD
-          ? minBy(v, 'offset')
-          : maxBy(v, 'offset')
+        isBackward ? minBy(v, 'offset') : maxBy(v, 'offset')
       ).map((message) => ({
         offset: message?.offset || 0,
         partition: message?.partition || 0,
@@ -54,7 +55,11 @@ const MessagesTable: React.FC = () => {
           (v) => maxBy(v, 'offset')
         )
       )
-        .map(({ offset, partition }) => `${partition}::${offset}`)
+        .map(({ offset, partition }) => {
+          const offsetQuery = isBackward ? offset : offset + 1;
+
+          return `${partition}::${offsetQuery}`;
+        })
         .join(',');
 
       searchParams.set('seekTo', nextSeekTo);