Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit e771c99

Browse files
authored
Merge branch 'develop' into t3chguy/fix/7156
2 parents 1f795e5 + 972fcd1 commit e771c99

File tree

7 files changed

+59
-16
lines changed

7 files changed

+59
-16
lines changed

.github/codecov.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
coverage:
2+
status:
3+
patch:
4+
default:
5+
enabled: no
6+
if_not_found: success
7+
comment:
8+
layout: "diff, files"
9+
behavior: default
10+
require_changes: false
11+
require_base: no
12+
require_head: no
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Test coverage
2+
on:
3+
pull_request: {}
4+
push:
5+
branches: [develop, main, master]
6+
jobs:
7+
test-coverage:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v2
12+
13+
- name: Yarn cache
14+
uses: c-hive/gha-yarn-cache@v2
15+
16+
- name: Install Deps
17+
run: "./scripts/ci/install-deps.sh --ignore-scripts"
18+
19+
- name: Run tests with coverage
20+
run: "yarn install && yarn reskindex && yarn coverage"
21+
22+
- name: Upload coverage
23+
uses: codecov/codecov-action@v2
24+
with:
25+
verbose: true

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@
231231
"<rootDir>/src/**/*.{js,ts,tsx}"
232232
],
233233
"coverageReporters": [
234-
"text"
234+
"text",
235+
"json"
235236
]
236237
}
237238
}

res/css/views/rooms/_EventTile.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ $left-gutter: 64px;
968968
.mx_EventTile_content,
969969
.mx_HiddenBody,
970970
.mx_RedactedBody,
971+
.mx_MPollBody,
971972
.mx_ReplyChain_wrapper {
972973
margin-left: 36px;
973974
margin-right: 8px;

src/components/views/rooms/BasicMessageComposer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
348348
parts = deserializedParts;
349349
} else {
350350
const text = event.clipboardData.getData("text/plain");
351-
parts = parsePlainTextMessage(text, partCreator);
351+
parts = parsePlainTextMessage(text, partCreator, { shouldEscape: false });
352352
}
353353
this.modifiedFlag = true;
354354
const range = getRangeForSelection(this.editorRef.current, model, document.getSelection());

src/components/views/rooms/ThreadSummary.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,13 @@ const ThreadSummary = ({ mxEvent, thread }: IProps) => {
6868

6969
export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
7070
const cli = useContext(MatrixClientContext);
71-
const lastReply = useTypedEventEmitterState(thread, ThreadEvent.Update, () => thread.lastReply());
71+
const lastReply = useTypedEventEmitterState(thread, ThreadEvent.Update, () => thread.replyToEvent);
7272
const preview = useAsyncMemo(async () => {
73+
if (!lastReply) return;
7374
await cli.decryptEventIfNeeded(lastReply);
7475
return MessagePreviewStore.instance.generatePreviewForEvent(lastReply);
7576
}, [lastReply]);
77+
if (!preview) return null;
7678

7779
const sender = thread.roomState.getSentinelMember(lastReply.getSender());
7880
return <>
@@ -83,13 +85,11 @@ export const ThreadMessagePreview = ({ thread }: Pick<IProps, "thread">) => {
8385
height={24}
8486
className="mx_ThreadInfo_avatar"
8587
/>
86-
{ preview && (
87-
<div className="mx_ThreadInfo_content">
88-
<span className="mx_ThreadInfo_message-preview">
89-
{ preview }
90-
</span>
91-
</div>
92-
) }
88+
<div className="mx_ThreadInfo_content">
89+
<span className="mx_ThreadInfo_message-preview">
90+
{ preview }
91+
</span>
92+
</div>
9393
</>;
9494
};
9595

src/editor/deserialize.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ function isListChild(n: Node): boolean {
5252
return LIST_TYPES.includes(n.parentNode?.nodeName);
5353
}
5454

55-
function parseAtRoomMentions(text: string, pc: PartCreator): Part[] {
55+
function parseAtRoomMentions(text: string, pc: PartCreator, shouldEscape = true): Part[] {
5656
const ATROOM = "@room";
5757
const parts: Part[] = [];
5858
text.split(ATROOM).forEach((textPart, i, arr) => {
5959
if (textPart.length) {
60-
parts.push(...pc.plainWithEmoji(escape(textPart)));
60+
parts.push(...pc.plainWithEmoji(shouldEscape ? escape(textPart) : textPart));
6161
}
6262
// it's safe to never append @room after the last textPart
6363
// as split will report an empty string at the end if
@@ -261,13 +261,17 @@ function parseHtmlMessage(html: string, pc: PartCreator, isQuotedMessage: boolea
261261
return parts;
262262
}
263263

264-
export function parsePlainTextMessage(body: string, pc: PartCreator, isQuotedMessage?: boolean): Part[] {
264+
export function parsePlainTextMessage(
265+
body: string,
266+
pc: PartCreator,
267+
opts: { isQuotedMessage?: boolean, shouldEscape?: boolean },
268+
): Part[] {
265269
const lines = body.split(/\r\n|\r|\n/g); // split on any new-line combination not just \n, collapses \r\n
266270
return lines.reduce((parts, line, i) => {
267-
if (isQuotedMessage) {
271+
if (opts.isQuotedMessage) {
268272
parts.push(pc.plain("> "));
269273
}
270-
parts.push(...parseAtRoomMentions(line, pc));
274+
parts.push(...parseAtRoomMentions(line, pc, opts.shouldEscape));
271275
const isLast = i === lines.length - 1;
272276
if (!isLast) {
273277
parts.push(pc.newline());
@@ -288,7 +292,7 @@ export function parseEvent(event: MatrixEvent, pc: PartCreator, { isQuotedMessag
288292
isRainbow = true;
289293
}
290294
} else {
291-
parts = parsePlainTextMessage(content.body || "", pc, isQuotedMessage);
295+
parts = parsePlainTextMessage(content.body || "", pc, { isQuotedMessage });
292296
}
293297

294298
if (isEmote && isRainbow) {

0 commit comments

Comments
 (0)