mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
routes: filtering by distance
This commit is contained in:
parent
c69da00b2a
commit
8248d9f166
12 changed files with 546 additions and 43 deletions
|
@ -51,4 +51,7 @@ export const keyPressed = ({ key }) => ({ type: ACTIONS.KEY_PRESSED, key });
|
|||
export const searchSetTitle = title => ({ type: ACTIONS.SEARCH_SET_TITLE, title });
|
||||
export const searchSetDistance = distance => ({ type: ACTIONS.SEARCH_SET_DISTANCE, distance });
|
||||
export const searchSetTab = tab => ({ type: ACTIONS.SEARCH_SET_TAB, tab });
|
||||
export const searchPutRoutes = list => ({ type: ACTIONS.SEARCH_PUT_ROUTES, list })
|
||||
export const searchSetLoading = loading => ({ type: ACTIONS.SEARCH_SET_LOADING, loading });
|
||||
|
||||
export const searchPutRoutes = payload => ({ type: ACTIONS.SEARCH_PUT_ROUTES, ...payload });
|
||||
|
||||
|
|
|
@ -56,4 +56,5 @@ export const ACTIONS = ({
|
|||
|
||||
SEARCH_SET_TAB: 'SEARCH_SET_TAB',
|
||||
SEARCH_PUT_ROUTES: 'SEARCH_PUT_ROUTES',
|
||||
SEARCH_SET_LOADING: 'SEARCH_SET_LOADING',
|
||||
}: { [key: String]: String });
|
||||
|
|
|
@ -128,11 +128,24 @@ const searchSetTab = (state, { tab = 'mine' }) => ({
|
|||
}
|
||||
});
|
||||
|
||||
const searchPutRoutes = (state, { list = [] }) => ({
|
||||
const searchPutRoutes = (state, { list = [], min, max }) => ({
|
||||
...state,
|
||||
routes: {
|
||||
...state.routes,
|
||||
list,
|
||||
filter: {
|
||||
...state.routes.filter,
|
||||
min: min || state.routes.filter.min,
|
||||
max: max || state.routes.filter.max,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const searchSetLoading = (state, { loading = false }) => ({
|
||||
...state,
|
||||
routes: {
|
||||
...state.routes,
|
||||
loading,
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -168,6 +181,7 @@ const HANDLERS = ({
|
|||
[ACTIONS.SEARCH_SET_DISTANCE]: searchSetDistance,
|
||||
[ACTIONS.SEARCH_SET_TAB]: searchSetTab,
|
||||
[ACTIONS.SEARCH_PUT_ROUTES]: searchPutRoutes,
|
||||
[ACTIONS.SEARCH_SET_LOADING]: searchSetLoading,
|
||||
}: { [key: String]: Function });
|
||||
|
||||
export const INITIAL_STATE = {
|
||||
|
@ -210,9 +224,10 @@ export const INITIAL_STATE = {
|
|||
title: '',
|
||||
starred: false,
|
||||
distance: [0, 300],
|
||||
|
||||
author: '',
|
||||
tab: 'mine',
|
||||
min: 0,
|
||||
max: 300,
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
postMap
|
||||
} from '$utils/api';
|
||||
import {
|
||||
hideRenderer, searchPutRoutes,
|
||||
hideRenderer, searchPutRoutes, searchSetLoading,
|
||||
setActiveSticker, setAddress,
|
||||
setChanged, setDialogActive,
|
||||
setEditing,
|
||||
|
@ -435,11 +435,11 @@ function* keyPressedSaga({ key }): void {
|
|||
|
||||
function* searchSetSaga() {
|
||||
const { id, token } = yield select(getUser);
|
||||
|
||||
yield delay(500);
|
||||
yield delay(1000);
|
||||
yield put(searchSetLoading(true));
|
||||
const { routes: { filter: { title, distance, tab } } } = yield select(getState);
|
||||
|
||||
const list = yield call(getRouteList, {
|
||||
const { list, min, max } = yield call(getRouteList, {
|
||||
id,
|
||||
token,
|
||||
title,
|
||||
|
@ -448,7 +448,8 @@ function* searchSetSaga() {
|
|||
starred: tab === 'starred',
|
||||
});
|
||||
|
||||
yield put(searchPutRoutes(list));
|
||||
yield put(searchPutRoutes({ list, min, max }));
|
||||
return yield put(searchSetLoading(false));
|
||||
}
|
||||
|
||||
export function* userSaga() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue