* feat(scanner): add LastScanError tracking to scanner status - Introduced LastScanErrorKey constant for error tracking. - Updated StatusInfo struct to include LastError field. - Modified scanner logic to store and retrieve last scan error. - Enhanced ScanStatus response to include error information. - Updated UI components to display last scan error when applicable. - Added tests to verify last scan error functionality. Signed-off-by: Deluan <deluan@navidrome.org> * feat(scanner): enhance scan status with type and elapsed time tracking - Added LastScanTypeKey and LastScanStartTimeKey constants for tracking scan type and start time. - Updated StatusInfo struct to include ScanType and ElapsedTime fields. - Implemented getScanInfo method to retrieve scan type, elapsed time, and last error. - Modified scanner logic to store scan type and start time during scans. - Enhanced ScanStatus response and UI components to display scan type and elapsed time. - Added formatShortDuration utility for better elapsed time representation. - Updated activity reducer to handle new scan status fields. Signed-off-by: Deluan <deluan@navidrome.org> * refactor(tests): consolidate controller status tests into a single file - Removed the old controller_status_test.go file. - Merged relevant tests into the new controller_test.go file for better organization and maintainability. - Ensured all existing test cases for controller status are preserved and functional. Signed-off-by: Deluan <deluan@navidrome.org> * Fix formatting issues * refactor(scanner): update getScanInfo method documentation --------- Signed-off-by: Deluan <deluan@navidrome.org>
46 lines
1 KiB
JavaScript
46 lines
1 KiB
JavaScript
import {
|
|
EVENT_REFRESH_RESOURCE,
|
|
EVENT_SCAN_STATUS,
|
|
EVENT_SERVER_START,
|
|
} from '../actions'
|
|
import config from '../config'
|
|
|
|
const initialState = {
|
|
scanStatus: {
|
|
scanning: false,
|
|
folderCount: 0,
|
|
count: 0,
|
|
error: '',
|
|
elapsedTime: 0,
|
|
},
|
|
serverStart: { version: config.version },
|
|
}
|
|
|
|
export const activityReducer = (previousState = initialState, payload) => {
|
|
const { type, data } = payload
|
|
|
|
switch (type) {
|
|
case EVENT_SCAN_STATUS: {
|
|
const elapsedTime = Number(data.elapsedTime) || 0
|
|
return { ...previousState, scanStatus: { ...data, elapsedTime } }
|
|
}
|
|
case EVENT_SERVER_START:
|
|
return {
|
|
...previousState,
|
|
serverStart: {
|
|
startTime: data.startTime && Date.parse(data.startTime),
|
|
version: data.version,
|
|
},
|
|
}
|
|
case EVENT_REFRESH_RESOURCE:
|
|
return {
|
|
...previousState,
|
|
refresh: {
|
|
lastReceived: Date.now(),
|
|
resources: data,
|
|
},
|
|
}
|
|
default:
|
|
return previousState
|
|
}
|
|
}
|