-
Notifications
You must be signed in to change notification settings - Fork 383
/
usersession.js
68 lines (67 loc) · 1.62 KB
/
usersession.js
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
/*
* Copyright 2020, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
import {
USER_SESSION_SAVED, USER_SESSION_LOADING, USER_SESSION_LOADED, USER_SESSION_REMOVED, ENABLE_AUTO_SAVE,
SAVE_MAP_CONFIG } from "../actions/usersession";
/**
* Handles state for userSession
* ```javascript
* {
* autoSave: true|false // enable/disable auto save
* id: id of the session
* session: the session loaded/saved
* config: the config of the map
* loading: {} // an object containing loading state
* }
* ```
* @name usersession
* @memberof reducers
*/
export default (state = {}, action) => {
switch (action.type) {
case ENABLE_AUTO_SAVE: {
return {
...state,
autoSave: action.enabled
};
}
case USER_SESSION_SAVED:
return {
...state,
id: action.id,
session: action.session
};
case USER_SESSION_LOADED:
return {
...state,
id: action.id,
session: action.session
};
case USER_SESSION_LOADING:
return {
...state,
loading: {
name: action.name,
value: action.value
}
};
case USER_SESSION_REMOVED:
return {
...state,
id: undefined,
session: undefined
};
case SAVE_MAP_CONFIG:
return {
...state,
config: action.config
};
default:
return state;
}
};