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