[ARVADOS-WORKBENCH2] updated: 1.2.0-377-ge49daa4

Git user git at public.curoverse.com
Sun Sep 16 16:35:04 EDT 2018


Summary of changes:
 .../progress-indicator/progress-indicator-reducer.ts | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

       via  e49daa4deeadf74cb0737501ed64bc41ba7a56d9 (commit)
      from  6f8e509988756deb7e05a760e718d1ade164fd19 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit e49daa4deeadf74cb0737501ed64bc41ba7a56d9
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date:   Sun Sep 16 22:35:00 2018 +0200

    Improved reducer state size
    
    Feature #14186
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>

diff --git a/src/store/progress-indicator/progress-indicator-reducer.ts b/src/store/progress-indicator/progress-indicator-reducer.ts
index 190ad13..f6a7347 100644
--- a/src/store/progress-indicator/progress-indicator-reducer.ts
+++ b/src/store/progress-indicator/progress-indicator-reducer.ts
@@ -4,24 +4,22 @@
 
 import { ProgressIndicatorAction, progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
 
-export interface ProgressIndicatorState {
-    [key: string]: {
-        working: boolean
-    };
-}
+export type ProgressIndicatorState = { id: string, working: boolean }[];
 
-const initialState: ProgressIndicatorState = {
-};
+const initialState: ProgressIndicatorState = [];
 
 export const progressIndicatorReducer = (state: ProgressIndicatorState = initialState, action: ProgressIndicatorAction) => {
+    const startWorking = (id: string) => state.find(p => p.working) ? state : state.concat({ id, working: true });
+    const stopWorking = (id: string) => state.filter(p => p.id !== id);
+
     return progressIndicatorActions.match(action, {
-        START: id => ({ ...state, [id]: { working: true } }),
-        STOP: id => ({ ...state, [id]: { working: false } }),
-        TOGGLE: ({ id, working }) => ({ ...state, [id]: { working }}),
+        START: id => startWorking(id),
+        STOP: id => stopWorking(id),
+        TOGGLE: ({ id, working }) => working ? startWorking(id) : stopWorking(id),
         default: () => state,
     });
 };
 
 export function isSystemWorking(state: ProgressIndicatorState): boolean {
-    return Object.keys(state).reduce((working, k) => working ? true : state[k].working, false);
+    return state.length > 0;
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list