[Glitch] Fix Web UI making duplicate search queries when scrolling
Port 4c1518a6f3
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
f61e29cc7e
commit
31dedf4697
|
@ -14,6 +14,7 @@ import {
|
||||||
SEARCH_SHOW,
|
SEARCH_SHOW,
|
||||||
SEARCH_EXPAND_REQUEST,
|
SEARCH_EXPAND_REQUEST,
|
||||||
SEARCH_EXPAND_SUCCESS,
|
SEARCH_EXPAND_SUCCESS,
|
||||||
|
SEARCH_EXPAND_FAIL,
|
||||||
SEARCH_HISTORY_UPDATE,
|
SEARCH_HISTORY_UPDATE,
|
||||||
} from 'flavours/glitch/actions/search';
|
} from 'flavours/glitch/actions/search';
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ export default function search(state = initialState, action) {
|
||||||
map.set('type', action.searchType);
|
map.set('type', action.searchType);
|
||||||
});
|
});
|
||||||
case SEARCH_FETCH_FAIL:
|
case SEARCH_FETCH_FAIL:
|
||||||
|
case SEARCH_EXPAND_FAIL:
|
||||||
return state.set('isLoading', false);
|
return state.set('isLoading', false);
|
||||||
case SEARCH_FETCH_SUCCESS:
|
case SEARCH_FETCH_SUCCESS:
|
||||||
return state.withMutations(map => {
|
return state.withMutations(map => {
|
||||||
|
@ -68,10 +70,10 @@ export default function search(state = initialState, action) {
|
||||||
map.set('isLoading', false);
|
map.set('isLoading', false);
|
||||||
});
|
});
|
||||||
case SEARCH_EXPAND_REQUEST:
|
case SEARCH_EXPAND_REQUEST:
|
||||||
return state.set('type', action.searchType);
|
return state.set('type', action.searchType).set('isLoading', true);
|
||||||
case SEARCH_EXPAND_SUCCESS:
|
case SEARCH_EXPAND_SUCCESS:
|
||||||
const results = action.searchType === 'hashtags' ? ImmutableOrderedSet(fromJS(action.results.hashtags)) : action.results[action.searchType].map(item => item.id);
|
const results = action.searchType === 'hashtags' ? ImmutableOrderedSet(fromJS(action.results.hashtags)) : action.results[action.searchType].map(item => item.id);
|
||||||
return state.updateIn(['results', action.searchType], list => list.union(results));
|
return state.updateIn(['results', action.searchType], list => list.union(results)).set('isLoading', false);
|
||||||
case SEARCH_HISTORY_UPDATE:
|
case SEARCH_HISTORY_UPDATE:
|
||||||
return state.set('recent', ImmutableOrderedSet(fromJS(action.recent)));
|
return state.set('recent', ImmutableOrderedSet(fromJS(action.recent)));
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue