Hydrate body ranges for story replies
This commit is contained in:
parent
9f85db3fd8
commit
be6e988a95
39 changed files with 221 additions and 172 deletions
|
@ -1,13 +1,14 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { BodyRangesType } from '../types/Util';
|
||||
import type { DraftBodyRangeType, DraftBodyRangesType } from '../types/Util';
|
||||
|
||||
export function getTextWithMentions(
|
||||
bodyRanges: BodyRangesType,
|
||||
bodyRanges: DraftBodyRangesType,
|
||||
text: string
|
||||
): string {
|
||||
return bodyRanges
|
||||
const sortableBodyRanges: Array<DraftBodyRangeType> = bodyRanges.slice();
|
||||
return sortableBodyRanges
|
||||
.sort((a, b) => b.start - a.start)
|
||||
.reduce((acc, { start, length, replacementText }) => {
|
||||
const left = acc.slice(0, start);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue