Memoize toasts to unstick them in AudioCapture
This commit is contained in:
parent
f4b0bade80
commit
7488fa5abc
2 changed files with 85 additions and 77 deletions
|
@ -1,7 +1,13 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// 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 classNames from 'classnames';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { useRestoreFocus } from '../hooks/useRestoreFocus';
|
import { useRestoreFocus } from '../hooks/useRestoreFocus';
|
||||||
|
@ -19,7 +25,8 @@ export type PropsType = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Toast = ({
|
export const Toast = memo(
|
||||||
|
({
|
||||||
autoDismissDisabled = false,
|
autoDismissDisabled = false,
|
||||||
children,
|
children,
|
||||||
className,
|
className,
|
||||||
|
@ -103,4 +110,5 @@ export const Toast = ({
|
||||||
root
|
root
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
};
|
}
|
||||||
|
);
|
||||||
|
|
|
@ -134,9 +134,9 @@ export const AudioCapture = ({
|
||||||
completeRecording(conversationId, onSendAudioRecording);
|
completeRecording(conversationId, onSendAudioRecording);
|
||||||
}, [conversationId, completeRecording, onSendAudioRecording]);
|
}, [conversationId, completeRecording, onSendAudioRecording]);
|
||||||
|
|
||||||
function closeToast() {
|
const closeToast = useCallback(() => {
|
||||||
setToastType(undefined);
|
setToastType(undefined);
|
||||||
}
|
}, []);
|
||||||
|
|
||||||
let toastElement: JSX.Element | undefined;
|
let toastElement: JSX.Element | undefined;
|
||||||
if (toastType === ToastType.VoiceNoteLimit) {
|
if (toastType === ToastType.VoiceNoteLimit) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue