mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 03:11:38 +03:00
sort subscribed communities when fetching
This commit is contained in:
parent
7820a52fa7
commit
87dc6853cb
@ -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)));
|
||||
|
@ -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<string, SubscribedCommunity>,
|
||||
|
Loading…
Reference in New Issue
Block a user