Skip to content

Commit

Permalink
FE: Messages: Explode partitions list in API (#331)
Browse files Browse the repository at this point in the history
Co-authored-by: Roman Zabaluev <[email protected]>
  • Loading branch information
Vixtir and Haarolean authored May 16, 2024
1 parent 42c236d commit ba92bcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions frontend/src/lib/hooks/api/topicMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ export const useTopicMessages = ({
default:
}

searchParams.getAll(MessagesFilterKeys.partitions).forEach((value) => {
requestParams.append(MessagesFilterKeys.partitions, value);
});

const partitions = searchParams.get(MessagesFilterKeys.partitions);
if (partitions !== null) {
requestParams.append(MessagesFilterKeys.partitions, partitions);
}
const { nextCursor, setNextCursor } = useMessageFiltersStore.getState();

const tempCompareUrl = new URLSearchParams(requestParams);
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/lib/hooks/useMessagesFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export function useMessagesFilters() {

const search = searchParams.get(MessagesFilterKeys.stringFilter) || '';

const partitions = searchParams.getAll(MessagesFilterKeys.partitions);
const partitions = (searchParams.get(MessagesFilterKeys.partitions) || '')
.split(',')
.filter((v) => v);

const smartFilterId =
searchParams.get(MessagesFilterKeys.activeFilterId) ||
Expand Down Expand Up @@ -166,9 +168,12 @@ export function useMessagesFilters() {
setSearchParams((params) => {
params.delete(MessagesFilterKeys.partitions);

values.forEach((option) => {
params.append(MessagesFilterKeys.partitions, option.value);
});
if (values.length) {
params.append(
MessagesFilterKeys.partitions,
values.map((v) => v.value).join(',')
);
}

return params;
});
Expand Down

0 comments on commit ba92bcb

Please sign in to comment.