diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js --- a/lib/reducers/master-reducer.js +++ b/lib/reducers/master-reducer.js @@ -49,9 +49,15 @@ threadInfos, ); + const [userStore, newUserInconsistencies] = reduceUserInfos( + state.userStore, + action, + ); + const newInconsistencies = [ ...newEntryInconsistencies, ...newThreadInconsistencies, + ...newUserInconsistencies, ]; // Only allow checkpoints to increase if we are connected // or if the action is a STATE_SYNC @@ -118,7 +124,7 @@ loadingStatuses: reduceLoadingStatuses(state.loadingStatuses, action), currentUserInfo: reduceCurrentUserInfo(state.currentUserInfo, action), threadStore, - userStore: reduceUserInfos(state.userStore, action), + userStore, messageStore, calendarFilters: reduceCalendarFilters( state.calendarFilters, diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js --- a/lib/reducers/user-reducer.js +++ b/lib/reducers/user-reducer.js @@ -20,6 +20,7 @@ import { stateSyncSpecs } from '../shared/state-sync/state-sync-specs.js'; import { updateSpecs } from '../shared/updates/update-specs.js'; import type { BaseAction } from '../types/redux-types.js'; +import type { UserInconsistencyReportCreationRequest } from '../types/report-types.js'; import { serverRequestTypes, processServerRequestsActionType, @@ -119,7 +120,10 @@ return state; } -function reduceUserInfos(state: UserStore, action: BaseAction): UserStore { +function reduceUserInfos( + state: UserStore, + action: BaseAction, +): [UserStore, $ReadOnlyArray] { if ( action.type === joinThreadActionTypes.success || action.type === newThreadActionTypes.success @@ -129,10 +133,13 @@ ); const updated = { ...state.userInfos, ...newUserInfos }; if (!_isEqual(state.userInfos)(updated)) { - return { - ...state, - userInfos: updated, - }; + return [ + { + ...state, + userInfos: updated, + }, + [], + ]; } } else if ( action.type === logOutActionTypes.success || @@ -141,12 +148,15 @@ action.payload.sessionChange.cookieInvalidated) ) { if (Object.keys(state.userInfos).length === 0) { - return state; + return [state, []]; } - return { - userInfos: {}, - inconsistencyReports: state.inconsistencyReports, - }; + return [ + { + userInfos: {}, + inconsistencyReports: state.inconsistencyReports, + }, + [], + ]; } else if ( action.type === logInActionTypes.success || action.type === siweAuthActionTypes.success || @@ -157,10 +167,13 @@ action.payload.userInfos, ); if (!_isEqual(state.userInfos)(newUserInfos)) { - return { - userInfos: newUserInfos, - inconsistencyReports: state.inconsistencyReports, - }; + return [ + { + userInfos: newUserInfos, + inconsistencyReports: state.inconsistencyReports, + }, + [], + ]; } } else if ( action.type === incrementalStateSyncActionType || @@ -180,21 +193,24 @@ { ...state.userInfos, ...newUserInfos }, ); if (!_isEqual(state.userInfos)(updated)) { - return { - ...state, - userInfos: updated, - }; + return [ + { + ...state, + userInfos: updated, + }, + [], + ]; } } else if (action.type === processServerRequestsActionType) { const checkStateRequest = action.payload.serverRequests.find( candidate => candidate.type === serverRequestTypes.CHECK_STATE, ); if (!checkStateRequest || !checkStateRequest.stateChanges) { - return state; + return [state, []]; } const { userInfos, deleteUserInfoIDs } = checkStateRequest.stateChanges; if (!userInfos && !deleteUserInfoIDs) { - return state; + return [state, []]; } const newUserInfos = { ...state.userInfos }; @@ -214,27 +230,28 @@ state.userInfos, newUserInfos, ); - return { - userInfos: newUserInfos, - inconsistencyReports: [ - ...state.inconsistencyReports, - ...newInconsistencies, - ], - }; + return [ + { + userInfos: newUserInfos, + inconsistencyReports: state.inconsistencyReports, + }, + newInconsistencies, + ]; } else if (action.type === updateUserAvatarActionTypes.success) { const newUserInfos = _keyBy(userInfo => userInfo.id)( action.payload.updates.userInfos, ); const updated = { ...state.userInfos, ...newUserInfos }; - return !_isEqual(state.userInfos)(updated) + const newState = !_isEqual(state.userInfos)(updated) ? { ...state, userInfos: updated, } : state; + return [newState, []]; } - return state; + return [state, []]; } export { reduceCurrentUserInfo, reduceUserInfos }; diff --git a/lib/utils/report-utils.js b/lib/utils/report-utils.js --- a/lib/utils/report-utils.js +++ b/lib/utils/report-utils.js @@ -32,7 +32,8 @@ enabledReports.mediaReports) || (report.type === reportTypes.ERROR && enabledReports.crashReports) || ((report.type === reportTypes.ENTRY_INCONSISTENCY || - report.type === reportTypes.THREAD_INCONSISTENCY) && + report.type === reportTypes.THREAD_INCONSISTENCY || + report.type === reportTypes.USER_INCONSISTENCY) && enabledReports.inconsistencyReports); return isReportTypeEnabled && isReportSizeValid(report);