mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
Fix composer localStorage key for draft event in a thread (#7526)
This commit is contained in:
parent
9ca429d15c
commit
61116377f3
2 changed files with 7 additions and 13 deletions
|
@ -451,9 +451,8 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
|
|||
|
||||
private get editorStateKey() {
|
||||
let key = `mx_cider_state_${this.props.room.roomId}`;
|
||||
const thread = this.props.replyToEvent?.getThread();
|
||||
if (thread) {
|
||||
key += `_${thread.id}`;
|
||||
if (this.props.relation?.rel_type === RelationType.Thread) {
|
||||
key += `_${this.props.relation.event_id}`;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import React from "react";
|
|||
import { act } from "react-dom/test-utils";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
import { mount } from 'enzyme';
|
||||
import { RelationType } from 'matrix-js-sdk/src/@types/event';
|
||||
|
||||
import SendMessageComposer, {
|
||||
createMessageContent,
|
||||
|
@ -290,13 +291,6 @@ describe('<SendMessageComposer/>', () => {
|
|||
});
|
||||
|
||||
it('correctly sets the editorStateKey for threads', () => {
|
||||
const mockThread ={
|
||||
getThread: () => {
|
||||
return {
|
||||
id: 'myFakeThreadId',
|
||||
};
|
||||
},
|
||||
} as any;
|
||||
const wrapper = mount(<MatrixClientContext.Provider value={mockClient}>
|
||||
<RoomContext.Provider value={roomContext}>
|
||||
|
||||
|
@ -304,14 +298,15 @@ describe('<SendMessageComposer/>', () => {
|
|||
room={mockRoom as any}
|
||||
placeholder=""
|
||||
permalinkCreator={new SpecPermalinkConstructor() as any}
|
||||
replyToEvent={mockThread}
|
||||
relation={{
|
||||
rel_type: RelationType.Thread,
|
||||
event_id: "myFakeThreadId",
|
||||
}}
|
||||
/>
|
||||
</RoomContext.Provider>
|
||||
</MatrixClientContext.Provider>);
|
||||
|
||||
const instance = wrapper.find(SendMessageComposerClass).instance();
|
||||
const key = instance.editorStateKey;
|
||||
|
||||
expect(key).toEqual('mx_cider_state_myfakeroom_myFakeThreadId');
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue