Fix logging for in call close confirmation

This commit is contained in:
ayumi-signal 2024-06-11 10:29:43 -07:00 committed by GitHub
parent 041347e30d
commit 9b781826a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 18 deletions

View file

@ -19,7 +19,7 @@ import type { ConversationType } from '../state/ducks/conversations';
import { calling } from '../services/calling';
import { resolveUsernameByLinkBase64 } from '../services/username';
import { writeProfile } from '../services/writeProfile';
import { isInCall as getIsInCall } from '../state/selectors/calling';
import { isInCall } from '../state/selectors/calling';
import { getConversationsWithCustomColorSelector } from '../state/selectors/conversations';
import { getCustomColors } from '../state/selectors/items';
import { themeChanged } from '../shims/themeChanged';
@ -128,7 +128,8 @@ export type IPCEventsCallbacksType = {
showGroupViaLink: (value: string) => Promise<void>;
showReleaseNotes: () => void;
showStickerPack: (packId: string, key: string) => void;
maybeRequestCloseConfirmation: () => Promise<boolean>;
requestCloseConfirmation: () => Promise<boolean>;
getIsInCall: () => boolean;
shutdown: () => Promise<void>;
unknownSignalLink: () => void;
getCustomColors: () => Record<string, CustomColorType>;
@ -632,12 +633,7 @@ export function createIPCEvents(
showUnknownSgnlLinkModal();
},
maybeRequestCloseConfirmation: async (): Promise<boolean> => {
const isInCall = getIsInCall(window.reduxStore.getState());
if (!isInCall) {
return true;
}
requestCloseConfirmation: async (): Promise<boolean> => {
try {
await new Promise<void>((resolve, reject) => {
showConfirmationDialog({
@ -655,20 +651,22 @@ export function createIPCEvents(
resolve: () => resolve(),
});
});
log.info('Close confirmed by user.');
if (isInCall) {
log.info('requestCloseConfirmation: Close confirmed by user.');
window.reduxActions.calling.hangUpActiveCall(
'User confirmed in-call close.'
);
}
return true;
} catch {
log.info('Close cancelled by user.');
log.info('requestCloseConfirmation: Close cancelled by user.');
return false;
}
},
getIsInCall: (): boolean => {
return isInCall(window.reduxStore.getState());
},
unknownSignalLink: () => {
log.warn('unknownSignalLink: Showing error dialog');
showUnknownSgnlLinkModal();

View file

@ -421,15 +421,15 @@ ipc.on('get-ready-for-shutdown', async () => {
});
ipc.on('maybe-request-close-confirmation', async () => {
const { maybeRequestCloseConfirmation } = window.Events;
if (!maybeRequestCloseConfirmation) {
const { getIsInCall, requestCloseConfirmation } = window.Events;
if (!getIsInCall || !getIsInCall() || !requestCloseConfirmation) {
ipc.send('received-close-confirmation', true);
return;
}
log.info('Requesting close confirmation.');
ipc.send('requested-close-confirmation');
const result = await maybeRequestCloseConfirmation();
const result = await requestCloseConfirmation();
ipc.send('received-close-confirmation', result);
});