fix: multiple bug fixes
isolated users, db backup, weird disconnect issues for long voice sessions,
This commit is contained in:
@@ -30,6 +30,16 @@ function mergePresenceServerIds(
|
||||
return normalizePresenceServerIds([...(existingServerIds ?? []), ...(incomingServerIds ?? [])]);
|
||||
}
|
||||
|
||||
function hasLivePeerTransport(user: User, connectedPeerIds: ReadonlySet<string>): boolean {
|
||||
if (connectedPeerIds.size === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return connectedPeerIds.has(user.id)
|
||||
|| connectedPeerIds.has(user.oderId)
|
||||
|| (!!user.peerId && connectedPeerIds.has(user.peerId));
|
||||
}
|
||||
|
||||
interface AvatarFields {
|
||||
avatarUrl?: string;
|
||||
avatarHash?: string;
|
||||
@@ -262,6 +272,10 @@ export const initialState: UsersState = usersAdapter.getInitialState({
|
||||
|
||||
export const usersReducer = createReducer(
|
||||
initialState,
|
||||
on(UsersActions.resetUsersState, () => ({
|
||||
...initialState
|
||||
})),
|
||||
|
||||
on(UsersActions.loadCurrentUser, (state) => ({
|
||||
...state,
|
||||
loading: true,
|
||||
@@ -344,10 +358,11 @@ export const usersReducer = createReducer(
|
||||
on(UsersActions.userJoined, (state, { user }) =>
|
||||
usersAdapter.upsertOne(buildPresenceAwareUser(state.entities[user.id], user), state)
|
||||
),
|
||||
on(UsersActions.syncServerPresence, (state, { roomId, users }) => {
|
||||
on(UsersActions.syncServerPresence, (state, { roomId, users, connectedPeerIds }) => {
|
||||
let nextState = state;
|
||||
|
||||
const seenUserIds = new Set<string>();
|
||||
const connectedPeerIdSet = new Set(connectedPeerIds ?? []);
|
||||
|
||||
for (const user of users) {
|
||||
seenUserIds.add(user.id);
|
||||
@@ -363,6 +378,7 @@ export const usersReducer = createReducer(
|
||||
&& user.id !== nextState.currentUserId
|
||||
&& user.presenceServerIds?.includes(roomId) === true
|
||||
&& !seenUserIds.has(user.id)
|
||||
&& !hasLivePeerTransport(user, connectedPeerIdSet)
|
||||
)
|
||||
.map((user) => ({
|
||||
id: user.id,
|
||||
|
||||
Reference in New Issue
Block a user