|
19 | 19 |
|
20 | 20 | import _ from 'lodash';
|
21 | 21 | import actions from 'actions/groups';
|
22 |
| -import { getService as getCommunitiesService } from 'services/communities'; |
23 | 22 | import { handleActions } from 'redux-actions';
|
24 |
| -import { getCommunityId } from 'routes/subdomains'; |
25 |
| -import { toFSA } from 'utils/redux'; |
26 |
| -import { getAuthTokens } from 'utils/tc'; |
27 | 23 |
|
28 | 24 | /**
|
29 | 25 | * Private. Given two user group maps, it adds to "dst" the root group from
|
@@ -102,50 +98,13 @@ function create(state) {
|
102 | 98 | }));
|
103 | 99 | }
|
104 | 100 |
|
105 |
| -/** |
106 |
| - * Loads into the state detailed information on the groups related to the |
107 |
| - * specified community. |
108 |
| - * |
109 |
| - * NOTE: This function is intended for the internal use only, it modifies |
110 |
| - * "state" argument! |
111 |
| - * |
112 |
| - * @param {String} communityId |
113 |
| - * @param {String} tokenV3 |
114 |
| - * @param {Object} state |
115 |
| - * @return {Promise} Resolves to the resulting state. |
116 |
| - */ |
117 |
| -function loadCommunityGroups(communityId, tokenV3, state) { |
118 |
| - let res = _.defaults(state, { groups: {}, loading: {} }); |
119 |
| - return getCommunitiesService(tokenV3).getMetadata(communityId).then((data) => { |
120 |
| - let ids = data.authorizedGroupIds || []; |
121 |
| - if (data.groupIds) ids = ids.concat(data.groupIds); |
122 |
| - res = onGetGroupsInit(res, { payload: ids }); |
123 |
| - return toFSA(actions.groups.getGroupsDone(ids, tokenV3)) |
124 |
| - .then((action) => { res = onGetGroupsDone(res, action); }) |
125 |
| - .then(() => res); |
126 |
| - }); |
127 |
| -} |
128 |
| - |
129 | 101 | /**
|
130 | 102 | * Reducer factory.
|
131 | 103 | * @param {Object} req Optional. ExpressJS HTTP request. If provided, the
|
132 | 104 | * intial state of the reducer will be tailored to the request.
|
133 | 105 | * @return {Promise} Resolves to the reducer.
|
134 | 106 | */
|
135 |
| -export function factory(req) { |
136 |
| - if (req) { |
137 |
| - /* For any location within any TC community we should load detailed |
138 |
| - * information about any related user groups. */ |
139 |
| - let communityId = getCommunityId(req.subdomains); |
140 |
| - if (!communityId && req.url.startsWith('/community')) { |
141 |
| - communityId = req.url.split('/')[2]; |
142 |
| - } |
143 |
| - if (communityId) { |
144 |
| - const tokenV3 = getAuthTokens(req).tokenV3; |
145 |
| - return loadCommunityGroups(communityId, tokenV3, {}) |
146 |
| - .then(res => create(res)); |
147 |
| - } |
148 |
| - } |
| 107 | +export function factory(/* req */) { |
149 | 108 | return Promise.resolve(create());
|
150 | 109 | }
|
151 | 110 |
|
|
0 commit comments