mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
Simplify group call peeking logic
Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
@@ -348,8 +348,7 @@ const actions = () => ({
|
||||
closeContactSpoofingReview: action('closeContactSpoofingReview'),
|
||||
reviewConversationNameCollision: action('reviewConversationNameCollision'),
|
||||
|
||||
peekGroupCallForTheFirstTime: action('peekGroupCallForTheFirstTime'),
|
||||
peekGroupCallIfItHasMembers: action('peekGroupCallIfItHasMembers'),
|
||||
maybePeekGroupCall: action('maybePeekGroupCall'),
|
||||
|
||||
viewStory: action('viewStory'),
|
||||
|
||||
|
||||
@@ -165,14 +165,13 @@ export type PropsActionsType = {
|
||||
setFocus?: boolean
|
||||
) => unknown;
|
||||
markMessageRead: (conversationId: string, messageId: string) => unknown;
|
||||
maybePeekGroupCall: (conversationId: string) => unknown;
|
||||
targetMessage: (messageId: string, conversationId: string) => unknown;
|
||||
setCenterMessage: (
|
||||
conversationId: string,
|
||||
messageId: string | undefined
|
||||
) => void;
|
||||
setIsNearBottom: (conversationId: string, isNearBottom: boolean) => void;
|
||||
peekGroupCallForTheFirstTime: (conversationId: string) => unknown;
|
||||
peekGroupCallIfItHasMembers: (conversationId: string) => unknown;
|
||||
reviewConversationNameCollision: () => void;
|
||||
scrollToOldestUnreadMention: (conversationId: string) => unknown;
|
||||
};
|
||||
@@ -590,15 +589,14 @@ export class Timeline extends React.Component<
|
||||
this.#cleanupGroupCallPeekTimeouts();
|
||||
|
||||
this.#delayedPeekTimeout = setTimeout(() => {
|
||||
const { id, peekGroupCallForTheFirstTime } = this.props;
|
||||
const { id, maybePeekGroupCall } = this.props;
|
||||
this.#delayedPeekTimeout = undefined;
|
||||
peekGroupCallForTheFirstTime(id);
|
||||
}, 500);
|
||||
maybePeekGroupCall(id);
|
||||
|
||||
this.#peekInterval = setInterval(() => {
|
||||
const { id, peekGroupCallIfItHasMembers } = this.props;
|
||||
peekGroupCallIfItHasMembers(id);
|
||||
}, MINUTE);
|
||||
this.#peekInterval = setInterval(() => {
|
||||
maybePeekGroupCall(id);
|
||||
}, MINUTE);
|
||||
}, 500);
|
||||
}
|
||||
|
||||
#cleanupGroupCallPeekTimeouts(): void {
|
||||
|
||||
@@ -1880,41 +1880,33 @@ function joinedAdhocCall(
|
||||
};
|
||||
}
|
||||
|
||||
function peekGroupCallForTheFirstTime(
|
||||
function maybePeekGroupCall(
|
||||
conversationId: string
|
||||
): ThunkAction<void, RootStateType, unknown, PeekGroupCallFulfilledActionType> {
|
||||
return (dispatch, getState) => {
|
||||
const call = getOwn(getState().calling.callsByConversation, conversationId);
|
||||
const shouldPeek =
|
||||
!call || (isGroupOrAdhocCallState(call) && !call.peekInfo);
|
||||
const callMode = call?.callMode ?? CallMode.Group;
|
||||
if (callMode === CallMode.Direct) {
|
||||
|
||||
if (call && !isGroupOrAdhocCallState(call)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldPeek) {
|
||||
const existingPeekInfo = call?.peekInfo;
|
||||
|
||||
// We peek if:
|
||||
// 1. this is the first time since app has started that we've peeked, or
|
||||
// 2. we've peeked prior and there is an ongoing group call
|
||||
if (existingPeekInfo == null) {
|
||||
doGroupCallPeek({
|
||||
conversationId,
|
||||
callMode,
|
||||
callMode: call?.callMode ?? CallMode.Group,
|
||||
dispatch,
|
||||
getState,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function peekGroupCallIfItHasMembers(
|
||||
conversationId: string
|
||||
): ThunkAction<void, RootStateType, unknown, PeekGroupCallFulfilledActionType> {
|
||||
return (dispatch, getState) => {
|
||||
const call = getOwn(getState().calling.callsByConversation, conversationId);
|
||||
const shouldPeek =
|
||||
} else if (
|
||||
call &&
|
||||
isGroupOrAdhocCallState(call) &&
|
||||
call.joinState === GroupCallJoinState.NotJoined &&
|
||||
call.peekInfo &&
|
||||
call.peekInfo.deviceCount > 0;
|
||||
if (shouldPeek) {
|
||||
existingPeekInfo.deviceCount > 0
|
||||
) {
|
||||
doGroupCallPeek({
|
||||
conversationId,
|
||||
callMode: call.callMode,
|
||||
@@ -3088,13 +3080,12 @@ export const actions = {
|
||||
handleCallLinkDelete,
|
||||
joinedAdhocCall,
|
||||
leaveCurrentCallAndStartCallingLobby,
|
||||
maybePeekGroupCall,
|
||||
onObservedRemoteMute,
|
||||
onOutgoingVideoCallInConversation,
|
||||
onOutgoingAudioCallInConversation,
|
||||
openSystemPreferencesAction,
|
||||
outgoingCall,
|
||||
peekGroupCallForTheFirstTime,
|
||||
peekGroupCallIfItHasMembers,
|
||||
peekNotConnectedGroupCall,
|
||||
receiveGroupCallReactions,
|
||||
receiveIncomingDirectCall,
|
||||
|
||||
@@ -209,8 +209,7 @@ export const SmartTimeline = memo(function SmartTimeline({
|
||||
setIsNearBottom,
|
||||
targetMessage,
|
||||
} = useConversationsActions();
|
||||
const { peekGroupCallForTheFirstTime, peekGroupCallIfItHasMembers } =
|
||||
useCallingActions();
|
||||
const { maybePeekGroupCall } = useCallingActions();
|
||||
|
||||
const getTimestampForMessage = useCallback(
|
||||
(messageId: string): undefined | number => {
|
||||
@@ -282,14 +281,13 @@ export const SmartTimeline = memo(function SmartTimeline({
|
||||
loadNewestMessages={loadNewestMessages}
|
||||
loadOlderMessages={loadOlderMessages}
|
||||
markMessageRead={markMessageRead}
|
||||
maybePeekGroupCall={maybePeekGroupCall}
|
||||
messageChangeCounter={messageChangeCounter}
|
||||
messageLoadingState={messageLoadingState}
|
||||
updateVisibleMessages={
|
||||
AttachmentDownloadManager.updateVisibleTimelineMessages
|
||||
}
|
||||
oldestUnseenIndex={oldestUnseenIndex}
|
||||
peekGroupCallForTheFirstTime={peekGroupCallForTheFirstTime}
|
||||
peekGroupCallIfItHasMembers={peekGroupCallIfItHasMembers}
|
||||
renderCollidingAvatars={renderCollidingAvatars}
|
||||
renderContactSpoofingReviewDialog={renderContactSpoofingReviewDialog}
|
||||
renderHeroRow={renderHeroRow}
|
||||
|
||||
Reference in New Issue
Block a user