diff options
Diffstat (limited to 'sdnr/wt/odlux/apps/connectApp/src/handlers')
-rw-r--r-- | sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx | 1 | ||||
-rw-r--r-- | sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx | 27 |
2 files changed, 20 insertions, 8 deletions
diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx index 26d02c4e9..dd9e3e1df 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/connectAppRootHandler.tsx @@ -4,7 +4,6 @@ import { IMountedNetworkElementsState, mountedNetworkElementsActionHandler } fro import { IConnectionStatusLogState, connectionStatusLogActionHandler } from './connectionStatusLogHandler'; export interface IConnectAppStoreState { - requiredNetworkElements: IRequiredNetworkElementsState; mountedNetworkElements: IMountedNetworkElementsState; connectionStatusLog: IConnectionStatusLogState; diff --git a/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx b/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx index 70b4d8f2a..db86b99c2 100644 --- a/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx +++ b/sdnr/wt/odlux/apps/connectApp/src/handlers/mountedNetworkElementsHandler.tsx @@ -1,7 +1,7 @@ import { IActionHandler } from '../../../../framework/src/flux/action'; import { - AddMountedNetworkElement, + AddOrUpdateMountedNetworkElement, AllMountedNetworkElementsLoadedAction, LoadAllMountedNetworkElementsAction, RemoveMountedNetworkElement, @@ -28,7 +28,7 @@ export const mountedNetworkElementsActionHandler: IActionHandler<IMountedNetwork ...state, busy: true }; - + } else if (action instanceof AllMountedNetworkElementsLoadedAction) { if (!action.error && action.mountedNetworkElements) { state = { @@ -42,11 +42,24 @@ export const mountedNetworkElementsActionHandler: IActionHandler<IMountedNetwork busy: false }; } - } else if (action instanceof AddMountedNetworkElement) { - action.mountedNetworkElement && (state = { - ...state, - elements: [...state.elements, action.mountedNetworkElement], - }); + } else if (action instanceof AddOrUpdateMountedNetworkElement) { + if (!action.mountedNetworkElement) return state; // should handle error here + const index = state.elements.findIndex(el => el.mountId === (action.mountedNetworkElement && action.mountedNetworkElement.mountId)); + if (index > -1) { + state = { + ...state, + elements: [ + ...state.elements.slice(0, index), + action.mountedNetworkElement, + ...state.elements.slice(index + 1) + ] + } + } else { + state = { + ...state, + elements: [...state.elements, action.mountedNetworkElement], + } + }; } else if (action instanceof RemoveMountedNetworkElement) { state = { ...state, |