fix: join upon friend add

This commit is contained in:
cha0s 2020-07-21 00:39:53 -05:00
parent 375a00cfe4
commit d30103d375

View File

@ -35,6 +35,7 @@ import {
} from '../../common/state/user';
import {
fetchUsernames,
usernamesSelector,
} from '~/common/state/usernames';
import {socket} from '~/client/hooks/useSocket';
@ -43,6 +44,13 @@ const effects = {
[addFriendship]: ({dispatch}, {payload: {addeeId, adderId}}) => {
dispatch(fetchUsernames([addeeId, adderId]));
},
[confirmFriendship]: ({dispatch, getState}, {payload: {addeeId, adderId}}) => {
const state = getState();
const id = idSelector(state);
const otherId = id === addeeId ? adderId : addeeId;
const name = usernamesSelector(state)[otherId];
dispatch(submitJoin({channel: `/u/${name}`, id}));
},
[join]: ({dispatch}, {payload: {messages, users}}) => {
const ids = new Set();
Object.values(messages).map((message) => message.owner).forEach((id) => ids.add(id));