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

This commit is contained in:
Scott Nonnenberg 2022-03-31 18:06:56 -07:00 committed by GitHub
parent bb250d4fb5
commit 85989fda3c
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'), unblurAvatar: action('unblurAvatar'),
peekGroupCallForTheFirstTime: action('peekGroupCallForTheFirstTime'), peekGroupCallForTheFirstTime: action('peekGroupCallForTheFirstTime'),
peekGroupCallIfItHasMembers: action('peekGroupCallIfItHasMembers'),
}); });
const renderItem = ({ const renderItem = ({

View file

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

View file

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

View file

@ -372,6 +372,10 @@ const doGroupCallPeek = (
return; return;
} }
log.info(
`doGroupCallPeek/groupv2(${conversation.groupId}): Found ${peekInfo.deviceCount} devices`
);
await calling.updateCallHistoryForGroupCall(conversationId, peekInfo); await calling.updateCallHistoryForGroupCall(conversationId, peekInfo);
const formattedPeekInfo = calling.formatGroupCallPeekInfoForRedux(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( function peekNotConnectedGroupCall(
payload: PeekNotConnectedGroupCallType payload: PeekNotConnectedGroupCallType
): ThunkAction<void, RootStateType, unknown, PeekGroupCallFulfilledActionType> { ): ThunkAction<void, RootStateType, unknown, PeekGroupCallFulfilledActionType> {
@ -1310,6 +1331,7 @@ export const actions = {
openSystemPreferencesAction, openSystemPreferencesAction,
outgoingCall, outgoingCall,
peekGroupCallForTheFirstTime, peekGroupCallForTheFirstTime,
peekGroupCallIfItHasMembers,
peekNotConnectedGroupCall, peekNotConnectedGroupCall,
receiveIncomingDirectCall, receiveIncomingDirectCall,
receiveIncomingGroupCall, receiveIncomingGroupCall,