quintodrome/ui/src/reducers/activityReducer.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
901 B
JavaScript
Raw Normal View History

import {
EVENT_REFRESH_RESOURCE,
EVENT_SCAN_STATUS,
EVENT_SERVER_START,
} from '../actions'
2021-06-21 09:42:14 -08:00
import config from '../config'
2020-11-13 14:40:33 -09:00
2021-06-21 09:42:14 -08:00
const initialState = {
scanStatus: { scanning: false, folderCount: 0, count: 0 },
2021-06-21 09:42:14 -08:00
serverStart: { version: config.version },
}
2021-06-21 09:42:14 -08:00
export const activityReducer = (previousState = initialState, payload) => {
const { type, data } = payload
switch (type) {
case EVENT_SCAN_STATUS:
return { ...previousState, scanStatus: data }
2020-11-13 14:40:33 -09:00
case EVENT_SERVER_START:
return {
...previousState,
serverStart: {
startTime: data.startTime && Date.parse(data.startTime),
2021-06-21 09:42:14 -08:00
version: data.version,
2020-11-13 14:40:33 -09:00
},
}
case EVENT_REFRESH_RESOURCE:
return {
...previousState,
refresh: {
lastReceived: Date.now(),
resources: data,
},
}
default:
return previousState
}
}