[Glitch] Add explore page to web UI
Port d4592bbfcd
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
import {
|
||||
SEARCH_CHANGE,
|
||||
SEARCH_CLEAR,
|
||||
SEARCH_FETCH_REQUEST,
|
||||
SEARCH_FETCH_FAIL,
|
||||
SEARCH_FETCH_SUCCESS,
|
||||
SEARCH_SHOW,
|
||||
SEARCH_EXPAND_SUCCESS,
|
||||
@ -17,6 +19,7 @@ const initialState = ImmutableMap({
|
||||
submitted: false,
|
||||
hidden: false,
|
||||
results: ImmutableMap(),
|
||||
isLoading: false,
|
||||
searchTerm: '',
|
||||
});
|
||||
|
||||
@ -37,12 +40,22 @@ export default function search(state = initialState, action) {
|
||||
case COMPOSE_MENTION:
|
||||
case COMPOSE_DIRECT:
|
||||
return state.set('hidden', true);
|
||||
case SEARCH_FETCH_REQUEST:
|
||||
return state.set('isLoading', true);
|
||||
case SEARCH_FETCH_FAIL:
|
||||
return state.set('isLoading', false);
|
||||
case SEARCH_FETCH_SUCCESS:
|
||||
return state.set('results', ImmutableMap({
|
||||
accounts: ImmutableList(action.results.accounts.map(item => item.id)),
|
||||
statuses: ImmutableList(action.results.statuses.map(item => item.id)),
|
||||
hashtags: fromJS(action.results.hashtags),
|
||||
})).set('submitted', true).set('searchTerm', action.searchTerm);
|
||||
return state.withMutations(map => {
|
||||
map.set('results', ImmutableMap({
|
||||
accounts: ImmutableList(action.results.accounts.map(item => item.id)),
|
||||
statuses: ImmutableList(action.results.statuses.map(item => item.id)),
|
||||
hashtags: fromJS(action.results.hashtags),
|
||||
}));
|
||||
|
||||
map.set('submitted', true);
|
||||
map.set('searchTerm', action.searchTerm);
|
||||
map.set('isLoading', false);
|
||||
});
|
||||
case SEARCH_EXPAND_SUCCESS:
|
||||
const results = action.searchType === 'hashtags' ? fromJS(action.results.hashtags) : action.results[action.searchType].map(item => item.id);
|
||||
return state.updateIn(['results', action.searchType], list => list.concat(results));
|
||||
|
Reference in New Issue
Block a user