Skip to content

Commit

Permalink
Add comments to improve the understanding of the logic of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivm committed Dec 8, 2023
1 parent 3cc3570 commit 2057a71
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Board/Board.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export class BoardContainer extends Component {

// Loggedin user?
if ('name' in userData && 'email' in userData) {
await this.handleApiUpdates(tile);
await this.handleApiUpdates(tile); // this function could mutate tthe tile
return;
}

Expand Down Expand Up @@ -1125,6 +1125,7 @@ export class BoardContainer extends Component {
//update the parent
updateBoard(parentBoardData);
}
// Untill here all is with shorts ids
//api updates
if (tile && tile.type === 'board') {
//child becomes parent
Expand Down Expand Up @@ -1166,6 +1167,10 @@ export class BoardContainer extends Component {
)
.then(parentBoardId => {
if (createParentBoard) {
console.log('parent board created', parentBoardData);
/* Here the parentBoardData is not updated with the values
that updatedApiObjects store on the API. Inside the boards are already updated
an the value is not replaced because the oldboard Id was replaced on the updateApiObjects inside createApiBoardSuccess */
replaceBoard(
{ ...parentBoardData },
{ ...parentBoardData, id: parentBoardId }
Expand Down
4 changes: 4 additions & 0 deletions src/components/Board/Board.reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ function tileReducer(board, action) {
return {
...board,
tiles: [...board.tiles, { ...action.tile }]
/* some times when a tile folder is created here the last tile change loadBoard to a long Id with no reason
action tile before this copy has a short ID*/
};
case DELETE_TILES:
return {
Expand Down Expand Up @@ -165,6 +167,8 @@ function boardReducer(state = initialState, action) {

if (prev.id !== current.id) {
const boardIndex = boards.findIndex(b => b.id === prev.id);
/* On create a parent board the prev board doesn't exist with a short Id
because is already replaced by a long one */
if (boardIndex >= 0) {
boards[boardIndex] = current;
}
Expand Down

0 comments on commit 2057a71

Please sign in to comment.