Memoize toasts to unstick them in AudioCapture

This commit is contained in:
Josh Perez 2021-10-12 15:09:00 -04:00 committed by GitHub
parent f4b0bade80
commit 7488fa5abc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 85 additions and 77 deletions

View file

@ -1,7 +1,13 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { KeyboardEvent, MouseEvent, ReactNode, useEffect } from 'react';
import React, {
KeyboardEvent,
MouseEvent,
ReactNode,
memo,
useEffect,
} from 'react';
import classNames from 'classnames';
import { createPortal } from 'react-dom';
import { useRestoreFocus } from '../hooks/useRestoreFocus';
@ -19,7 +25,8 @@ export type PropsType = {
};
};
export const Toast = ({
export const Toast = memo(
({
autoDismissDisabled = false,
children,
className,
@ -103,4 +110,5 @@ export const Toast = ({
root
)
: null;
};
}
);

View file

@ -134,9 +134,9 @@ export const AudioCapture = ({
completeRecording(conversationId, onSendAudioRecording);
}, [conversationId, completeRecording, onSendAudioRecording]);
function closeToast() {
const closeToast = useCallback(() => {
setToastType(undefined);
}
}, []);
let toastElement: JSX.Element | undefined;
if (toastType === ToastType.VoiceNoteLimit) {