diff --git a/src/redux/actions/communitiesAction.js b/src/redux/actions/communitiesAction.js index c84a74cad..cc06174f8 100644 --- a/src/redux/actions/communitiesAction.js +++ b/src/redux/actions/communitiesAction.js @@ -46,7 +46,7 @@ export const fetchSubscribedCommunities = (username) => { dispatch({ type: FETCH_SUBSCRIBED_COMMUNITIES }); getSubscriptions(username) .then((res) => { - res.forEach((item) => item.push(true)); + res.forEach((item) => item.push(true)).sort((a, b) => a[1].localeCompare(b[1])); //add true value for subscribe status and sort alphabatically dispatch(fetchSubscribedCommunitiesSuccess(res)); }) .catch((err) => dispatch(fetchSubscribedCommunitiesFail(err))); diff --git a/src/utils/communitiesUtils.ts b/src/utils/communitiesUtils.ts index 91438b4fc..77c3a1841 100644 --- a/src/utils/communitiesUtils.ts +++ b/src/utils/communitiesUtils.ts @@ -1,5 +1,11 @@ import { SubscribedCommunity } from '../redux/reducers/cacheReducer'; +/** + * Accepts Array of subscription items arrays as 1st argument, community cache map as second argument. + * Returns single array with union of both lists, sorted alphabatically + * Example subList = [['id', 'title', 'role', 'label', 'true/false'],['id', 'title', 'role', 'label', 'true/false']] + * + **/ export const mergeSubCommunitiesCacheInSubList = ( subList: any[], cacheMap: Map,