Skip to content

Commit

Permalink
Merge pull request #1727 from RodriSanchez1/fix/defaultBoardsIncluded
Browse files Browse the repository at this point in the history
Fix / Unexpected behaviour on change default boards included
  • Loading branch information
tomivm authored Jul 4, 2024
2 parents 92aac1a + 04bac9a commit 8f11447
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/api/communicators.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"email": "support@cboard.io",
"rootBoard": "root",
"boards": ["root"],
"defaultBoardBlackList": []
"defaultBoardBlackList": [],
"defaultBoardsIncluded": [
{ "nameOnJSON": "advanced", "homeBoard": "root" },
{ "nameOnJSON": "picSeePal", "homeBoard": "jjmlUcQs19" }
]
}
]
9 changes: 6 additions & 3 deletions src/components/Board/Board.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/components/Communicator/Communicator.actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/Communicator/Communicator.reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f11447

Please sign in to comment.