CompositionArea: Don't unconditionally apply draft contents if empty
This commit is contained in:
parent
cdc68d1c34
commit
f93b4235d5
4 changed files with 17 additions and 12 deletions
|
@ -372,14 +372,23 @@ export function CompositionArea({
|
|||
messageCompositionId,
|
||||
messageCompositionId
|
||||
);
|
||||
const previousSendCounter = usePrevious(sendCounter, sendCounter);
|
||||
useEffect(() => {
|
||||
if (!inputApiRef.current) {
|
||||
return;
|
||||
}
|
||||
if (previousMessageCompositionId !== messageCompositionId) {
|
||||
if (
|
||||
previousMessageCompositionId !== messageCompositionId ||
|
||||
previousSendCounter !== sendCounter
|
||||
) {
|
||||
inputApiRef.current.reset();
|
||||
}
|
||||
}, [messageCompositionId, previousMessageCompositionId]);
|
||||
}, [
|
||||
messageCompositionId,
|
||||
sendCounter,
|
||||
previousMessageCompositionId,
|
||||
previousSendCounter,
|
||||
]);
|
||||
|
||||
const insertEmoji = useCallback(
|
||||
(e: EmojiPickDataType) => {
|
||||
|
@ -393,12 +402,12 @@ export function CompositionArea({
|
|||
|
||||
const previousConversationId = usePrevious(conversationId, conversationId);
|
||||
useEffect(() => {
|
||||
if (!draftText) {
|
||||
inputApiRef.current?.setContents('');
|
||||
if (conversationId === previousConversationId) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (conversationId === previousConversationId) {
|
||||
if (!draftText) {
|
||||
inputApiRef.current?.setContents('');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise<void> => {
|
|||
const deltaList = new Array<number>();
|
||||
for (let runId = 0; runId < RUN_COUNT + DISCARD_COUNT; runId += 1) {
|
||||
debug('finding composition input and clicking it');
|
||||
const input = await app.waitForEnabledComposer(250);
|
||||
const input = await app.waitForEnabledComposer();
|
||||
|
||||
debug('entering message text');
|
||||
await input.type(`my message ${runId}`);
|
||||
|
|
|
@ -78,7 +78,7 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise<void> => {
|
|||
const deltaList = new Array<number>();
|
||||
for (let runId = 0; runId < RUN_COUNT + DISCARD_COUNT; runId += 1) {
|
||||
debug('finding composition input and clicking it');
|
||||
const input = await app.waitForEnabledComposer(250);
|
||||
const input = await app.waitForEnabledComposer();
|
||||
|
||||
debug('entering message text');
|
||||
await input.type(`my message ${runId}`);
|
||||
|
|
|
@ -10,7 +10,6 @@ import type {
|
|||
IPCResponse as ChallengeResponseType,
|
||||
} from '../challenge';
|
||||
import type { ReceiptType } from '../types/Receipt';
|
||||
import { sleep } from '../util/sleep';
|
||||
|
||||
export type AppLoadedInfoType = Readonly<{
|
||||
loadTime: number;
|
||||
|
@ -62,7 +61,7 @@ export class App extends EventEmitter {
|
|||
this.privApp.on('close', () => this.emit('close'));
|
||||
}
|
||||
|
||||
public async waitForEnabledComposer(sleepTimeout = 1000): Promise<Locator> {
|
||||
public async waitForEnabledComposer(): Promise<Locator> {
|
||||
const window = await this.getWindow();
|
||||
const composeArea = window.locator(
|
||||
'.composition-area-wrapper, .conversation .ConversationView'
|
||||
|
@ -72,9 +71,6 @@ export class App extends EventEmitter {
|
|||
);
|
||||
await composeContainer.waitFor();
|
||||
|
||||
// Let quill start up
|
||||
await sleep(sleepTimeout);
|
||||
|
||||
return composeContainer.locator('.ql-editor');
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue