More peeking of group calls to prevent out-of-date member info

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2022-04-01 10:48:36 -07:00 committed by GitHub
parent ee3a35d05d
commit 3ed5c36d58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 2 deletions

View File

@ -417,6 +417,7 @@ const actions = () => ({
unblurAvatar: action('unblurAvatar'),
peekGroupCallForTheFirstTime: action('peekGroupCallForTheFirstTime'),
peekGroupCallIfItHasMembers: action('peekGroupCallIfItHasMembers'),
});
const renderItem = ({

View File

@ -46,6 +46,7 @@ import {
setScrollBottom,
} from '../../util/scrollUtil';
import { LastSeenIndicator } from './LastSeenIndicator';
import { MINUTE } from '../../util/durations';
const AT_BOTTOM_THRESHOLD = 15;
const AT_BOTTOM_DETECTOR_STYLE = { height: AT_BOTTOM_THRESHOLD };
@ -162,6 +163,7 @@ export type PropsActionsType = {
onDelete: (conversationId: string) => unknown;
onUnblock: (conversationId: string) => unknown;
peekGroupCallForTheFirstTime: (conversationId: string) => unknown;
peekGroupCallIfItHasMembers: (conversationId: string) => unknown;
removeMember: (conversationId: string) => unknown;
selectMessage: (messageId: string, conversationId: string) => unknown;
clearSelectedMessage: () => unknown;
@ -221,6 +223,7 @@ const getActions = createSelector(
'onDelete',
'onUnblock',
'peekGroupCallForTheFirstTime',
'peekGroupCallIfItHasMembers',
'removeMember',
'selectMessage',
'clearSelectedMessage',
@ -281,6 +284,7 @@ export class Timeline extends React.Component<
private hasRecentlyScrolledTimeout?: NodeJS.Timeout;
private delayedPeekTimeout?: NodeJS.Timeout;
private peekInterval?: NodeJS.Timeout;
override state: StateType = {
hasRecentlyScrolled: true,
@ -562,18 +566,27 @@ export class Timeline extends React.Component<
this.delayedPeekTimeout = setTimeout(() => {
const { id, peekGroupCallForTheFirstTime } = this.props;
this.delayedPeekTimeout = undefined;
peekGroupCallForTheFirstTime(id);
}, 500);
this.peekInterval = setInterval(() => {
const { id, peekGroupCallIfItHasMembers } = this.props;
peekGroupCallIfItHasMembers(id);
}, MINUTE);
}
public override componentWillUnmount(): void {
const { delayedPeekTimeout } = this;
const { delayedPeekTimeout, peekInterval } = this;
window.unregisterForActive(this.markNewestBottomVisibleMessageRead);
this.intersectionObserver?.disconnect();
clearTimeoutIfNecessary(delayedPeekTimeout);
if (peekInterval) {
clearInterval(peekInterval);
}
}
public override getSnapshotBeforeUpdate(

View File

@ -102,7 +102,6 @@ export class RecorderClass {
async stop(): Promise<Blob | undefined> {
if (!this.recorder) {
log.warn('Recorder/stop: Called with no recorder');
return;
}

View File

@ -372,6 +372,10 @@ const doGroupCallPeek = (
return;
}
log.info(
`doGroupCallPeek/groupv2(${conversation.groupId}): Found ${peekInfo.deviceCount} devices`
);
await calling.updateCallHistoryForGroupCall(conversationId, peekInfo);
const formattedPeekInfo = calling.formatGroupCallPeekInfoForRedux(peekInfo);
@ -988,6 +992,23 @@ function peekGroupCallForTheFirstTime(
};
}
function peekGroupCallIfItHasMembers(
conversationId: string
): ThunkAction<void, RootStateType, unknown, PeekGroupCallFulfilledActionType> {
return (dispatch, getState) => {
const call = getOwn(getState().calling.callsByConversation, conversationId);
const shouldPeek =
call &&
call.callMode === CallMode.Group &&
call.joinState === GroupCallJoinState.NotJoined &&
call.peekInfo &&
call.peekInfo.deviceCount > 0;
if (shouldPeek) {
doGroupCallPeek(conversationId, dispatch, getState);
}
};
}
function peekNotConnectedGroupCall(
payload: PeekNotConnectedGroupCallType
): ThunkAction<void, RootStateType, unknown, PeekGroupCallFulfilledActionType> {
@ -1310,6 +1331,7 @@ export const actions = {
openSystemPreferencesAction,
outgoingCall,
peekGroupCallForTheFirstTime,
peekGroupCallIfItHasMembers,
peekNotConnectedGroupCall,
receiveIncomingDirectCall,
receiveIncomingGroupCall,