diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-08-16 10:22:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-16 10:22:50 -0700 |
commit | 819340dd3c34e89e8cd7126c6f1172aba7a8ebec (patch) | |
tree | 91a1a4e3f45d7a0e7c32f530319c6349c778ccfc /src/lib/api/index.ts | |
parent | 5379561934f6249fbbecf33ed0cd10d2d30128f0 (diff) | |
download | voidsky-819340dd3c34e89e8cd7126c6f1172aba7a8ebec.tar.zst |
Shorten links in composer to reduce char usage (#1188)
* Modify toShortUrl() to always include the full domain * Shorten links in the composer to save on characters * Apply some limits to the link card suggester
Diffstat (limited to 'src/lib/api/index.ts')
-rw-r--r-- | src/lib/api/index.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index bb4ff8fcb..4ecd32046 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -14,6 +14,7 @@ import {isNetworkError} from 'lib/strings/errors' import {LinkMeta} from '../link-meta/link-meta' import {isWeb} from 'platform/detection' import {ImageModel} from 'state/models/media/image' +import {shortenLinks} from 'lib/strings/rich-text-manip' export interface ExternalEmbedDraft { uri: string @@ -92,7 +93,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { | AppBskyEmbedRecordWithMedia.Main | undefined let reply - const rt = new RichText( + let rt = new RichText( {text: opts.rawText.trim()}, { cleanNewlines: true, @@ -101,6 +102,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { opts.onStateChange?.('Processing...') await rt.detectFacets(store.agent) + rt = shortenLinks(rt) // filter out any mention facets that didn't map to a user rt.facets = rt.facets?.filter(facet => { |