fix: filter result rendering fixed in topics

This commit is contained in:
Mehak Nasir
2022-12-06 19:42:55 +05:00
committed by Mehak Nasir
parent 37053e9bd3
commit 31a66f6832
4 changed files with 22 additions and 6 deletions

View File

@@ -94,7 +94,13 @@ const threadsSlice = createSlice({
}
state.status = RequestStatus.SUCCESSFUL;
state.threadsById = { ...state.threadsById, ...payload.threadsById };
state.threadsInTopic = mergeThreadsInTopics(state.threadsInTopic, payload.threadsInTopic);
// filter
if (payload.isFilterChanged) {
state.threadsInTopic = { ...payload.threadsInTopic };
} else {
state.threadsInTopic = mergeThreadsInTopics(state.threadsInTopic, payload.threadsInTopic);
}
state.avatars = { ...state.avatars, ...payload.avatars };
state.nextPage = (payload.page < payload.pagination.numPages) ? payload.page + 1 : null;
state.totalPages = payload.pagination.numPages;

View File

@@ -102,6 +102,7 @@ export function fetchThreads(courseId, {
author = null,
filters = {},
page = 1,
isFilterChanged,
countFlagged,
} = {}) {
const options = {
@@ -141,7 +142,7 @@ export function fetchThreads(courseId, {
const data = await getThreads(courseId, options);
const normalisedData = normaliseThreads(camelCaseObject(data), topicIds);
dispatch(fetchThreadsSuccess({
...normalisedData, page, author, textSearchRewrite: data.text_search_rewrite,
...normalisedData, page, author, textSearchRewrite: data.text_search_rewrite, isFilterChanged,
}));
} catch (error) {
if (getHttpErrorStatus(error) === 403) {