Hydrate body ranges for story replies

This commit is contained in:
Fedor Indutny 2022-11-09 20:59:36 -08:00 committed by GitHub
parent 9f85db3fd8
commit be6e988a95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 221 additions and 172 deletions

View file

@ -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);