diff --git a/ts/components/CompositionArea.tsx b/ts/components/CompositionArea.tsx index 589e287f7..e61001da6 100644 --- a/ts/components/CompositionArea.tsx +++ b/ts/components/CompositionArea.tsx @@ -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; } diff --git a/ts/test-mock/benchmarks/group_send_bench.ts b/ts/test-mock/benchmarks/group_send_bench.ts index 157cd2432..684052972 100644 --- a/ts/test-mock/benchmarks/group_send_bench.ts +++ b/ts/test-mock/benchmarks/group_send_bench.ts @@ -124,7 +124,7 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise => { const deltaList = new Array(); 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}`); diff --git a/ts/test-mock/benchmarks/send_bench.ts b/ts/test-mock/benchmarks/send_bench.ts index 822558a0e..e8c36f1ba 100644 --- a/ts/test-mock/benchmarks/send_bench.ts +++ b/ts/test-mock/benchmarks/send_bench.ts @@ -78,7 +78,7 @@ Bootstrap.benchmark(async (bootstrap: Bootstrap): Promise => { const deltaList = new Array(); 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}`); diff --git a/ts/test-mock/playwright.ts b/ts/test-mock/playwright.ts index 769d0a823..6912245f4 100644 --- a/ts/test-mock/playwright.ts +++ b/ts/test-mock/playwright.ts @@ -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 { + public async waitForEnabledComposer(): Promise { 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'); }