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