summaryrefslogtreecommitdiff
path: root/scraper/client/search/search.reducer.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-03-19 20:45:24 +0100
committerJules Laplace <julescarbon@gmail.com>2019-03-19 20:45:24 +0100
commit7eb3c04ef85fa0311bdf30b24df2aba102757878 (patch)
treebfb1354dcbed9486b43e75c7d2507a725212db24 /scraper/client/search/search.reducer.js
parent46885570e527a2bb8a374e7044afdf0a4c5ba07e (diff)
rebuild site
Diffstat (limited to 'scraper/client/search/search.reducer.js')
-rw-r--r--scraper/client/search/search.reducer.js84
1 files changed, 0 insertions, 84 deletions
diff --git a/scraper/client/search/search.reducer.js b/scraper/client/search/search.reducer.js
deleted file mode 100644
index b9de60bd..00000000
--- a/scraper/client/search/search.reducer.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import * as types from '../types'
-import session from '../session'
-
-const initialState = () => ({
- query: { reset: true },
- browse: { reset: true },
- options: {
- thumbnailSize: session('thumbnailSize') || 'th',
- perPage: parseInt(session('perPage'), 10) || 50,
- groupByHash: session('groupByHash'),
- }
-})
-
-const loadingState = {
- query: {
- query: { loading: true },
- results: []
- },
- loading: {
- loading: true
- }
-}
-
-export default function searchReducer(state = initialState(), action) {
- // console.log(action.type, action)
- switch (action.type) {
- case types.search.loading:
- if (action.tag === 'query' && action.offset) {
- return {
- ...state,
- query: {
- ...state.query,
- loadingMore: true,
- }
- }
- }
- return {
- ...state,
- [action.tag]: loadingState[action.tag] || loadingState.loading,
- }
-
- case types.search.loaded:
- if (action.tag === 'query' && action.offset) {
- return {
- ...state,
- query: {
- query: action.data.query,
- results: [
- ...state.query.results,
- ...action.data.results,
- ],
- loadingMore: false,
- }
- }
- }
- return {
- ...state,
- [action.tag]: action.data,
- }
-
- case types.search.error:
- return {
- ...state,
- [action.tag]: { error: action.err },
- }
-
- case types.search.panic:
- return {
- ...initialState(),
- }
-
- case types.search.update_options:
- session.setAll(action.opt)
- return {
- ...state,
- options: {
- ...action.opt,
- }
- }
-
- default:
- return state
- }
-}