1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
import { Action, handleActions } from "redux-actions";
import {
MOVIES_DELETE_ITEMS,
MOVIES_DELETE_WANTED_ITEMS,
MOVIES_UPDATE_BLACKLIST,
MOVIES_UPDATE_HISTORY_LIST,
MOVIES_UPDATE_LIST,
MOVIES_UPDATE_WANTED_LIST,
} from "../constants";
import { AsyncAction } from "../types";
import { defaultAOS } from "../utils";
import {
deleteOrderListItemBy,
updateAsyncState,
updateOrderIdState,
} from "../utils/mapper";
const reducer = handleActions<ReduxStore.Movie, any>(
{
[MOVIES_UPDATE_WANTED_LIST]: (
state,
action: AsyncAction<AsyncDataWrapper<Wanted.Movie>>
) => {
return {
...state,
wantedMovieList: updateOrderIdState(
action,
state.wantedMovieList,
"radarrId"
),
};
},
[MOVIES_DELETE_WANTED_ITEMS]: (state, action: Action<number[]>) => {
return {
...state,
wantedMovieList: deleteOrderListItemBy(action, state.wantedMovieList),
};
},
[MOVIES_UPDATE_HISTORY_LIST]: (
state,
action: AsyncAction<History.Movie[]>
) => {
return {
...state,
historyList: updateAsyncState(action, state.historyList.data),
};
},
[MOVIES_UPDATE_LIST]: (
state,
action: AsyncAction<AsyncDataWrapper<Item.Movie>>
) => {
return {
...state,
movieList: updateOrderIdState(action, state.movieList, "radarrId"),
};
},
[MOVIES_DELETE_ITEMS]: (state, action: Action<number[]>) => {
return {
...state,
movieList: deleteOrderListItemBy(action, state.movieList),
};
},
[MOVIES_UPDATE_BLACKLIST]: (
state,
action: AsyncAction<Blacklist.Movie[]>
) => {
return {
...state,
blacklist: updateAsyncState(action, state.blacklist.data),
};
},
},
{
movieList: defaultAOS(),
wantedMovieList: defaultAOS(),
historyList: { updating: true, data: [] },
blacklist: { updating: true, data: [] },
}
);
export default reducer;
|