From a5cd0337f6ea55c0dbf5418339c0c829be044897 Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Wed, 3 Jul 2024 21:32:14 -0300 Subject: [PATCH 1/2] Add hasValidDefaultBoardsIncluded to avoid unexpected behaviours --- src/components/Board/Board.actions.js | 9 ++++++--- src/components/Communicator/Communicator.actions.js | 5 ++++- src/components/Communicator/Communicator.reducer.js | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/components/Board/Board.actions.js b/src/components/Board/Board.actions.js index 9c11e2578..9e0990bb0 100644 --- a/src/components/Board/Board.actions.js +++ b/src/components/Board/Board.actions.js @@ -123,9 +123,12 @@ export function changeDefaultBoard(selectedBoardNameOnJson) { return initialDefaultBoardsIncluded; }; - const defaultBoardsIncluded = - activeCommunicator.defaultBoardsIncluded || - fallbackInitialDefaultBoardsIncluded(activeCommunicator); + const hasValidDefaultBoardsIncluded = !!activeCommunicator + .defaultBoardsIncluded?.length; + + const defaultBoardsIncluded = hasValidDefaultBoardsIncluded + ? activeCommunicator.defaultBoardsIncluded + : fallbackInitialDefaultBoardsIncluded(activeCommunicator); const defaultBoardsNamesIncluded = defaultBoardsIncluded?.map( includedBoardObject => includedBoardObject.nameOnJSON diff --git a/src/components/Communicator/Communicator.actions.js b/src/components/Communicator/Communicator.actions.js index 5dec5e3a0..f575f8afc 100644 --- a/src/components/Communicator/Communicator.actions.js +++ b/src/components/Communicator/Communicator.actions.js @@ -214,7 +214,10 @@ export function verifyAndUpsertCommunicator( updatedCommunicatorData.id = shortid.generate(); updatedCommunicatorData.boards = [...communicator.boards]; - if (!!communicator.defaultBoardsIncluded) { + const hasValidDefaultBoardsIncluded = !!communicator.defaultBoardsIncluded + ?.length; + + if (hasValidDefaultBoardsIncluded) { updatedCommunicatorData.defaultBoardsIncluded = communicator.defaultBoardsIncluded.map( item => ({ ...item }) ); diff --git a/src/components/Communicator/Communicator.reducer.js b/src/components/Communicator/Communicator.reducer.js index 5b19818b2..7c6ec7130 100644 --- a/src/components/Communicator/Communicator.reducer.js +++ b/src/components/Communicator/Communicator.reducer.js @@ -165,7 +165,11 @@ function communicatorReducer(state = initialState, action) { nameOnJSON: 'advanced', homeBoard: 'root' }; - const defaultBoardsIncluded = activeCommunicator.defaultBoardsIncluded + + const hasValidDefaultBoardsIncluded = !!activeCommunicator + .defaultBoardsIncluded?.length; + + const defaultBoardsIncluded = hasValidDefaultBoardsIncluded ? [ ...activeCommunicator.defaultBoardsIncluded, action.defaultBoardData From 04bac9abd831aefd191ff1398135f0418d1e09e0 Mon Sep 17 00:00:00 2001 From: Rodri Sanchez Date: Wed, 3 Jul 2024 21:32:56 -0300 Subject: [PATCH 2/2] Add default values for defaultBoardsIncluded on intialState --- src/api/communicators.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/api/communicators.json b/src/api/communicators.json index c76acc5ed..840795576 100644 --- a/src/api/communicators.json +++ b/src/api/communicators.json @@ -7,6 +7,10 @@ "email": "support@cboard.io", "rootBoard": "root", "boards": ["root"], - "defaultBoardBlackList": [] + "defaultBoardBlackList": [], + "defaultBoardsIncluded": [ + { "nameOnJSON": "advanced", "homeBoard": "root" }, + { "nameOnJSON": "picSeePal", "homeBoard": "jjmlUcQs19" } + ] } ]