mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
09.43.2018 1a21e0d3baca3870611a1fe712027a559d9a4b93
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
import {VERSION_RELOAD_FAILED, VERSION_RELOADED, VERSION_REQUEST_RELOAD} from '../actions/types';
import {fetchNewDictionary} from '../utilities/i18n';
 
const initialState = {
    version: '0.0.0',
    buildDate: 'never',
    language: null,
    loading: false
};
 
const reducer = (state = initialState, action) => {
    switch (action.type) {
        case VERSION_REQUEST_RELOAD:
            return Object.assign({}, state, {
                loading: true,
                failed: false
            });
        case VERSION_RELOADED:
 
            if (state.version !== action.payload.version ||
                state.language !== action.payload.language) {
                //console.log("reducers/version.js: state.version=" + state.version + ", payload.version=" + action.payload.version + ", state.lang=" + state.language + ", payload.lang=" + action.payload.language);
                fetchNewDictionary(action.payload.version, action.payload.language);
            }
 
            return Object.assign({}, state, {
                loading: false,
                failed: false,
                version: action.payload.version,
                language: action.payload.language,
                buildDate: action.payload.buildDate,
                updateVersion: action.payload.updateVersion
            });
        case VERSION_RELOAD_FAILED:
            return Object.assign({}, state, {
                loading: false,
                failed: true
            });
        default:
            return state;
    }
};
 
export default reducer;