Filter incoming bodyRanges, also filter before display
This commit is contained in:
parent
ec1246f60a
commit
4c9baaef80
10 changed files with 84 additions and 126 deletions
|
@ -48,7 +48,7 @@ import type {
|
|||
HydratedBodyRangeMention,
|
||||
HydratedBodyRangesType,
|
||||
} from '../../types/BodyRange';
|
||||
import { BodyRange } from '../../types/BodyRange';
|
||||
import { BodyRange, hydrateRanges } from '../../types/BodyRange';
|
||||
import type { AssertProps } from '../../types/Util';
|
||||
import type { LinkPreviewType } from '../../types/message/LinkPreviews';
|
||||
import { getMentionsRegex } from '../../types/Message';
|
||||
|
@ -317,22 +317,9 @@ export const processBodyRanges = (
|
|||
return undefined;
|
||||
}
|
||||
|
||||
return bodyRanges
|
||||
.map(range => {
|
||||
const { conversationSelector } = options;
|
||||
|
||||
if (BodyRange.isMention(range)) {
|
||||
const conversation = conversationSelector(range.mentionUuid);
|
||||
|
||||
return {
|
||||
...range,
|
||||
conversationID: conversation.id,
|
||||
replacementText: conversation.title,
|
||||
};
|
||||
}
|
||||
return range;
|
||||
})
|
||||
.sort((a, b) => b.start - a.start);
|
||||
return hydrateRanges(bodyRanges, options.conversationSelector)?.sort(
|
||||
(a, b) => b.start - a.start
|
||||
);
|
||||
};
|
||||
|
||||
export const extractHydratedMentions = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue