mirror of
https://github.com/bendtherules/github-delete-unused-repos.git
synced 2026-08-18 13:52:59 +00:00
Reformat reducers.ts
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
import { Reducer, createStore, Store } from 'redux';
|
import { Reducer, createStore, Store } from 'redux';
|
||||||
import { devToolsEnhancer } from 'redux-devtools-extension';
|
import { devToolsEnhancer } from 'redux-devtools-extension';
|
||||||
|
|
||||||
import { ApplicationState, FilterStatus, RepoFilterState, FilterSteps } from './model';
|
import {
|
||||||
|
ApplicationState,
|
||||||
|
FilterStatus,
|
||||||
|
RepoFilterState,
|
||||||
|
FilterSteps,
|
||||||
|
} from './model';
|
||||||
import {
|
import {
|
||||||
ActionNames,
|
ActionNames,
|
||||||
InitUserNameArgs,
|
InitUserNameArgs,
|
||||||
@@ -10,13 +15,11 @@ import {
|
|||||||
ActionsType,
|
ActionsType,
|
||||||
} from './actions';
|
} from './actions';
|
||||||
|
|
||||||
|
|
||||||
function calculateAggregateStatus(repoFilterState: RepoFilterState) {
|
function calculateAggregateStatus(repoFilterState: RepoFilterState) {
|
||||||
let aggregatedStatus = FilterStatus.pass;
|
let aggregatedStatus = FilterStatus.pass;
|
||||||
|
|
||||||
const filterStepValues = Object.values(FilterSteps) as FilterSteps[];
|
const filterStepValues = Object.values(FilterSteps) as FilterSteps[];
|
||||||
|
|
||||||
|
|
||||||
for (const stepName of filterStepValues) {
|
for (const stepName of filterStepValues) {
|
||||||
const stepStatus = repoFilterState[stepName].status;
|
const stepStatus = repoFilterState[stepName].status;
|
||||||
if (stepStatus === FilterStatus.fail) {
|
if (stepStatus === FilterStatus.fail) {
|
||||||
@@ -85,8 +88,9 @@ export const reducer: Reducer<ApplicationState, ActionsType> = (
|
|||||||
clonedRepoState.filterState[action.payload.filterStep] =
|
clonedRepoState.filterState[action.payload.filterStep] =
|
||||||
action.payload.filterState;
|
action.payload.filterState;
|
||||||
|
|
||||||
clonedRepoState.filterState[FilterSteps.aggregated].status =
|
clonedRepoState.filterState[
|
||||||
calculateAggregateStatus(clonedRepoState.filterState);
|
FilterSteps.aggregated
|
||||||
|
].status = calculateAggregateStatus(clonedRepoState.filterState);
|
||||||
|
|
||||||
clonedAppState.set(action.payload.repoName, clonedRepoState);
|
clonedAppState.set(action.payload.repoName, clonedRepoState);
|
||||||
return { ...state, repoStateMap: clonedAppState };
|
return { ...state, repoStateMap: clonedAppState };
|
||||||
|
|||||||
Reference in New Issue
Block a user