fixing message count problem when clearing or adding messages (#2029)

This commit is contained in:
Robert Azizbekyan 2022-05-30 11:38:46 +04:00 committed by GitHub
parent cc109a7125
commit cf6454c987
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions

View file

@ -39,11 +39,13 @@ const Overview: React.FC<Props> = ({
}) => { }) => {
const { isReadOnly } = React.useContext(ClusterContext); const { isReadOnly } = React.useContext(ClusterContext);
const messageCount = React.useMemo(() => { const messageCount = React.useMemo(
return (partitions || []).reduce((memo, partition) => { () =>
return memo + partition.offsetMax - partition.offsetMin; (partitions || []).reduce((memo, partition) => {
}, 0); return memo + partition.offsetMax - partition.offsetMin;
}, [partitions]); }, 0),
[partitions]
);
return ( return (
<> <>

View file

@ -6,7 +6,10 @@ import { useHistory, useParams } from 'react-router-dom';
import { clusterTopicMessagesPath } from 'lib/paths'; import { clusterTopicMessagesPath } from 'lib/paths';
import jsf from 'json-schema-faker'; import jsf from 'json-schema-faker';
import { messagesApiClient } from 'redux/reducers/topicMessages/topicMessagesSlice'; import { messagesApiClient } from 'redux/reducers/topicMessages/topicMessagesSlice';
import { fetchTopicMessageSchema } from 'redux/reducers/topics/topicsSlice'; import {
fetchTopicMessageSchema,
fetchTopicDetails,
} from 'redux/reducers/topics/topicsSlice';
import { useAppDispatch, useAppSelector } from 'lib/hooks/redux'; import { useAppDispatch, useAppSelector } from 'lib/hooks/redux';
import { alertAdded } from 'redux/reducers/alerts/alertsSlice'; import { alertAdded } from 'redux/reducers/alerts/alertsSlice';
import { now } from 'lodash'; import { now } from 'lodash';
@ -126,6 +129,7 @@ const SendMessage: React.FC = () => {
partition, partition,
}, },
}); });
dispatch(fetchTopicDetails({ clusterName, topicName }));
} catch (e) { } catch (e) {
dispatch( dispatch(
alertAdded({ alertAdded({

View file

@ -4,6 +4,7 @@ import { TopicMessage, Configuration, MessagesApi } from 'generated-sources';
import { BASE_PARAMS } from 'lib/constants'; import { BASE_PARAMS } from 'lib/constants';
import { getResponse } from 'lib/errorHandling'; import { getResponse } from 'lib/errorHandling';
import { showSuccessAlert } from 'redux/reducers/alerts/alertsSlice'; import { showSuccessAlert } from 'redux/reducers/alerts/alertsSlice';
import { fetchTopicDetails } from 'redux/reducers/topics/topicsSlice';
const apiClientConf = new Configuration(BASE_PARAMS); const apiClientConf = new Configuration(BASE_PARAMS);
export const messagesApiClient = new MessagesApi(apiClientConf); export const messagesApiClient = new MessagesApi(apiClientConf);
@ -23,7 +24,7 @@ export const clearTopicMessages = createAsyncThunk<
topicName, topicName,
partitions, partitions,
}); });
dispatch(fetchTopicDetails({ clusterName, topicName }));
dispatch( dispatch(
showSuccessAlert({ showSuccessAlert({
id: `message-${topicName}-${clusterName}-${partitions}`, id: `message-${topicName}-${clusterName}-${partitions}`,