Skip to content

Commit

Permalink
Merge branch 'master' into pr/tomivm/1718
Browse files Browse the repository at this point in the history
  • Loading branch information
RodriSanchez1 committed Jul 9, 2024
2 parents f8638f2 + f47f2b5 commit 100564e
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 10 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": "[email protected]",
"rootBoard": "root",
"boards": ["root"],
"defaultBoardBlackList": []
"defaultBoardBlackList": [],
"defaultBoardsIncluded": [
{ "nameOnJSON": "advanced", "homeBoard": "root" },
{ "nameOnJSON": "picSeePal", "homeBoard": "jjmlUcQs19" }
]
}
]
2 changes: 1 addition & 1 deletion src/api/corePicSeePal.json
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@
"sound": "",
"type": "folder",
"backgroundColor": "#2196F3",
"linkedBoard": false,
"linkedBoard": true,
"id": "auYUsFh3-qI"
}
],
Expand Down
20 changes: 20 additions & 0 deletions src/components/App/App.constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,23 @@ export const APP_LANGS = [
'zh-CN',
'zu-ZA' // for crowdin contextual translation
];

export const USER_DATA_PROPERTIES = [
'id',
'google',
'facebook',
'apple',
'name',
'role',
'provider',
'locale',
'password',
'location',
'email',
'isFirstLogin',
'birthdate',
'lastlogin',
'createdAt',
'updatedAt',
'authToken'
];
16 changes: 13 additions & 3 deletions src/components/App/App.reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
UPDATE_USER_DATA,
DISABLE_TOUR,
ENABLE_ALL_TOURS,
SET_UNLOGGED_USER_LOCATION
SET_UNLOGGED_USER_LOCATION,
USER_DATA_PROPERTIES
} from './App.constants';
import { LOGIN_SUCCESS, LOGOUT } from '../Account/Login/Login.constants';
import {
Expand Down Expand Up @@ -60,6 +61,15 @@ const initialState = {
userData: {}
};

const getKeysFromApiUserDataResponse = payload => {
const newUser = {};
if (!payload) return newUser;
USER_DATA_PROPERTIES.forEach(prop => {
if (payload[prop] !== undefined) newUser[prop] = payload[prop];
});
return newUser;
};

function appReducer(state = initialState, action) {
let displaySettings = { ...state.displaySettings };
let navigationSettings = { ...state.navigationSettings };
Expand Down Expand Up @@ -147,7 +157,7 @@ function appReducer(state = initialState, action) {
isFirstVisit: false,
displaySettings,
navigationSettings,
userData: action.payload || {}
userData: getKeysFromApiUserDataResponse(action.payload)
};
case LOGOUT:
return {
Expand All @@ -157,7 +167,7 @@ function appReducer(state = initialState, action) {
case UPDATE_USER_DATA:
return {
...state,
userData: action.userData
userData: getKeysFromApiUserDataResponse(action.userData)
};
case SET_UNLOGGED_USER_LOCATION:
return {
Expand Down
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 100564e

Please sign in to comment.