fix(users-context): phantom user (#20253)

* fix(users-context): add missing logs

* fix(user-persistent-data): collection publication selector for viewers

Fixes the collection's selector when publishing it to viewers.

* fix(users-context): correctly add user persistent data

Changes the logic of the add_user_persistent_data action in users
context, so that the user information already in the context is merged
with the new one. Also, do not flip the logged out status of users added
by user_persisted_data anymore.
This commit is contained in:
Arthur B. Grossi 2024-09-13 09:49:44 -03:00 committed by GitHub
parent 9a7249492b
commit c7b03ee13d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 12 deletions

View File

@ -34,7 +34,10 @@ async function usersPersistentData() {
meetingId,
$or: [
{
'shouldPersist.hasMessages': true,
'shouldPersist.hasMessages.public': true,
},
{
'shouldPersist.hasMessages.private': true,
},
{
loggedOut: false,

View File

@ -56,6 +56,7 @@ const Adapter = () => {
});
},
changed: (obj) => {
ChatLogger.debug('usersAdapter::observe::changed', obj);
dispatch({
type: ACTIONS.CHANGED,
value: {

View File

@ -27,6 +27,7 @@ const reducer = (state, action) => {
case ACTIONS.ADDED:
case ACTIONS.CHANGED: {
ChatLogger.debug('UsersContextProvider::reducer::added', { ...action });
const { user } = action.value;
const newState = { ...state };
@ -53,23 +54,22 @@ const reducer = (state, action) => {
return newState;
}
return state;
return state;
}
// USER PERSISTENT DATA
case ACTIONS.ADDED_USER_PERSISTENT_DATA: {
ChatLogger.debug('UsersContextProvider::reducer::added_user_persistent_data', { ...action });
const { user } = action.value;
if (state[user.meetingId] && state[user.meetingId][user.userId]) {
if (state[user.meetingId][user.userId].loggedOut) {
const newState = { ...state };
newState[user.meetingId][user.userId] = {
...state[user.meetingId][user.userId],
loggedOut: false,
};
return newState;
}
return state;
const newState = { ...state };
newState[user.meetingId][user.userId] = {
...state[user.meetingId][user.userId],
...user,
};
return newState;
}
const newState = { ...state };
@ -83,6 +83,8 @@ const reducer = (state, action) => {
return newState;
}
case ACTIONS.CHANGED_USER_PERSISTENT_DATA: {
ChatLogger.debug('UsersContextProvider::reducer::changed_user_persistent_data', { ...action });
const { user } = action.value;
const stateUser = state[user.meetingId][user.userId];
if (stateUser) {