Bluesky app fork with some witchin' additions 馃挮
witchsky.app
bluesky
fork
client
1// Kind of a hack. We needed some way to distinguish these.
2const USER_ALT_PREFIX = 'Alt: '
3const DEFAULT_ALT_PREFIX = 'ALT: '
4
5export function createGIFDescription(
6 tenorDescription: string,
7 preferredAlt: string = '',
8) {
9 preferredAlt = preferredAlt.trim()
10 if (preferredAlt !== '') {
11 return USER_ALT_PREFIX + preferredAlt
12 } else {
13 return DEFAULT_ALT_PREFIX + tenorDescription
14 }
15}
16
17export function parseAltFromGIFDescription(description: string): {
18 isPreferred: boolean
19 alt: string
20} {
21 if (description.startsWith(USER_ALT_PREFIX)) {
22 return {
23 isPreferred: true,
24 alt: description.replace(USER_ALT_PREFIX, ''),
25 }
26 } else if (description.startsWith(DEFAULT_ALT_PREFIX)) {
27 return {
28 isPreferred: false,
29 alt: description.replace(DEFAULT_ALT_PREFIX, ''),
30 }
31 }
32 return {
33 isPreferred: false,
34 alt: description,
35 }
36}