This repository has been archived on 2025-09-19. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
repertory-ui/src/redux/reducers/download_reducer.js
2021-03-10 21:14:32 -06:00

55 lines
1.2 KiB
JavaScript

import { createReducer } from '@reduxjs/toolkit';
import {
SET_DOWNLOAD_BEGIN,
setAllowDownload,
setDownloadEnd,
setDownloadProgress,
} from '../actions/download_actions';
const defaultDownloadState = {
DownloadActive: false,
DownloadingDependency: false,
DownloadingRelease: false,
DownloadingUpgrade: false,
DownloadName: '',
DownloadProgress: 0.0,
DownloadResult: null,
DownloadType: null,
};
export const downloadReducer = createReducer(
{
...defaultDownloadState,
AllowDownload: false,
},
{
[setAllowDownload]: (state, action) => {
return {
...state,
AllowDownload: action.payload,
};
},
[SET_DOWNLOAD_BEGIN]: (state, action) => {
return {
...state,
...defaultDownloadState,
DownloadActive: true,
DownloadName: action.payload.name,
DownloadType: action.payload.type,
DownloadURL: action.payload.url,
};
},
[setDownloadEnd]: (state, action) => {
return {
...state,
...defaultDownloadState,
DownloadResult: action.payload,
};
},
[setDownloadProgress]: (state, action) => {
return { ...state, DownloadProgress: action.payload };
},
}
);