feat: use t.gifs cdn for tenor search results
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
createStarterPackLinkFromAndroidReferrer,
|
createStarterPackLinkFromAndroidReferrer,
|
||||||
parseStarterPackUri,
|
parseStarterPackUri,
|
||||||
} from '#/lib/strings/starter-pack'
|
} from '#/lib/strings/starter-pack'
|
||||||
|
import {tenorUrlToBskyGifUrl} from '#/state/queries/tenor'
|
||||||
import {cleanError} from '../../src/lib/strings/errors'
|
import {cleanError} from '../../src/lib/strings/errors'
|
||||||
import {createFullHandle, makeValidHandle} from '../../src/lib/strings/handles'
|
import {createFullHandle, makeValidHandle} from '../../src/lib/strings/handles'
|
||||||
import {enforceLen} from '../../src/lib/strings/helpers'
|
import {enforceLen} from '../../src/lib/strings/helpers'
|
||||||
@@ -997,3 +998,18 @@ describe('createStarterPackGooglePlayUri', () => {
|
|||||||
expect(createStarterPackGooglePlayUri(undefined, 'rkey')).toEqual(null)
|
expect(createStarterPackGooglePlayUri(undefined, 'rkey')).toEqual(null)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('tenorUrlToBskyGifUrl', () => {
|
||||||
|
const inputs = [
|
||||||
|
'https://media.tenor.com/someID_AAAAC/someName.gif',
|
||||||
|
'https://media.tenor.com/someID/someName.gif',
|
||||||
|
]
|
||||||
|
|
||||||
|
it.each(inputs)(
|
||||||
|
'returns url with t.gifs.bsky.app as hostname for input url',
|
||||||
|
input => {
|
||||||
|
const out = tenorUrlToBskyGifUrl(input)
|
||||||
|
expect(out).toEqual(true)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
import {TextInput, View} from 'react-native'
|
import {type TextInput, View} from 'react-native'
|
||||||
import {useWindowDimensions} from 'react-native'
|
import {useWindowDimensions} from 'react-native'
|
||||||
import {Image} from 'expo-image'
|
import {Image} from 'expo-image'
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
@@ -15,13 +15,14 @@ import {logEvent} from '#/lib/statsig/statsig'
|
|||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import {
|
import {
|
||||||
Gif,
|
type Gif,
|
||||||
|
tenorUrlToBskyGifUrl,
|
||||||
useFeaturedGifsQuery,
|
useFeaturedGifsQuery,
|
||||||
useGifSearchQuery,
|
useGifSearchQuery,
|
||||||
} from '#/state/queries/tenor'
|
} from '#/state/queries/tenor'
|
||||||
import {ErrorScreen} from '#/view/com/util/error/ErrorScreen'
|
import {ErrorScreen} from '#/view/com/util/error/ErrorScreen'
|
||||||
import {ErrorBoundary} from '#/view/com/util/ErrorBoundary'
|
import {ErrorBoundary} from '#/view/com/util/ErrorBoundary'
|
||||||
import {ListMethods} from '#/view/com/util/List'
|
import {type ListMethods} from '#/view/com/util/List'
|
||||||
import {atoms as a, ios, native, useBreakpoints, useTheme, web} from '#/alf'
|
import {atoms as a, ios, native, useBreakpoints, useTheme, web} from '#/alf'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
@@ -316,7 +317,7 @@ export function GifPreview({
|
|||||||
t.atoms.bg_contrast_25,
|
t.atoms.bg_contrast_25,
|
||||||
]}
|
]}
|
||||||
source={{
|
source={{
|
||||||
uri: gif.media_formats.tinygif.url,
|
uri: tenorUrlToBskyGifUrl(gif.media_formats.tinygif.url),
|
||||||
}}
|
}}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
accessibilityLabel={gif.title}
|
accessibilityLabel={gif.title}
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ const IFRAME_HOST = isWeb
|
|||||||
? 'http://localhost:8100'
|
? 'http://localhost:8100'
|
||||||
: 'https://bsky.app'
|
: 'https://bsky.app'
|
||||||
: __DEV__ && !process.env.JEST_WORKER_ID
|
: __DEV__ && !process.env.JEST_WORKER_ID
|
||||||
? 'http://localhost:8100'
|
? 'http://localhost:8100'
|
||||||
: 'https://bsky.app'
|
: 'https://bsky.app'
|
||||||
|
|
||||||
export const embedPlayerSources = [
|
export const embedPlayerSources = [
|
||||||
'youtube',
|
'youtube',
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {getLocales} from 'expo-localization'
|
|||||||
import {keepPreviousData, useInfiniteQuery} from '@tanstack/react-query'
|
import {keepPreviousData, useInfiniteQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {GIF_FEATURED, GIF_SEARCH} from '#/lib/constants'
|
import {GIF_FEATURED, GIF_SEARCH} from '#/lib/constants'
|
||||||
|
import {logger} from '#/logger'
|
||||||
|
|
||||||
export const RQKEY_ROOT = 'gif-service'
|
export const RQKEY_ROOT = 'gif-service'
|
||||||
export const RQKEY_FEATURED = [RQKEY_ROOT, 'featured']
|
export const RQKEY_FEATURED = [RQKEY_ROOT, 'featured']
|
||||||
@@ -86,6 +87,18 @@ function createTenorApi<Input extends object>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function tenorUrlToBskyGifUrl(tenorUrl: string) {
|
||||||
|
let url
|
||||||
|
try {
|
||||||
|
url = new URL(tenorUrl)
|
||||||
|
} catch (e) {
|
||||||
|
logger.debug('invalid url passed to tenorUrlToBskyGifUrl()')
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
url.hostname = 't.gifs.bsky.app'
|
||||||
|
return url.href
|
||||||
|
}
|
||||||
|
|
||||||
export type Gif = {
|
export type Gif = {
|
||||||
/**
|
/**
|
||||||
* A Unix timestamp that represents when this post was created.
|
* A Unix timestamp that represents when this post was created.
|
||||||
|
|||||||
Reference in New Issue
Block a user