This commit is contained in:
vineyardbovines
2026-04-10 12:29:10 -04:00
parent 2e54eff27d
commit 2f08e54b3e
4 changed files with 28 additions and 3 deletions
+11
View File
@@ -15,6 +15,7 @@ import {Trans} from '@lingui/react/macro'
import {cleanError} from '#/lib/strings/errors'
import {
type Gif,
<<<<<<< Updated upstream
klipyStaticUrl,
useFeaturedGifsQuery as useKlipyFeaturedGifsQuery,
useGifSearchQuery as useKlipyGifSearchQuery,
@@ -22,6 +23,11 @@ import {
import {
useTenorFeaturedGifsQuery,
useTenorGifSearchQuery,
=======
gifPreviewUrl,
useFeaturedGifsQuery,
useGifSearchQuery,
>>>>>>> Stashed changes
} from '#/state/queries/tenor'
import {ErrorScreen} from '#/view/com/util/error/ErrorScreen'
import {ErrorBoundary} from '#/view/com/util/ErrorBoundary'
@@ -98,6 +104,7 @@ function GifList({
const [undeferredSearch, setSearch] = useState('')
const search = useThrottledValue(undeferredSearch, 500)
const {height} = useWindowDimensions()
const useKlipy = ax.features.enabled(ax.features.KlipyGifProviderEnable)
const isSearching = search.length > 0
const useKlipy = ax.features.enabled(ax.features.KlipyGifProviderEnable)
@@ -332,7 +339,11 @@ export function GifPreview({
t.atoms.bg_contrast_25,
]}
source={{
<<<<<<< Updated upstream
uri: klipyStaticUrl(gif.file.sm.gif.url),
=======
uri: gifPreviewUrl(gif.media_formats.tinygif.url),
>>>>>>> Stashed changes
}}
contentFit="cover"
accessibilityLabel={gif.title}
+3 -2
View File
@@ -191,11 +191,12 @@ export async function resolveGif(
gif: Gif,
): Promise<ResolvedExternalLink> {
const uri = `${gif.media_formats.gif.url}?hh=${gif.media_formats.gif.dims[1]}&ww=${gif.media_formats.gif.dims[0]}`
const altText = gif.content_description || gif.title
return {
type: 'external',
uri,
title: gif.content_description,
description: createGIFDescription(gif.content_description),
title: altText,
description: createGIFDescription(altText),
thumb: await imageToThumb(gif.media_formats.preview.url),
}
}
+12
View File
@@ -2,7 +2,10 @@ import {Platform} from 'react-native'
import {getLocales} from 'expo-localization'
import {keepPreviousData, useInfiniteQuery} from '@tanstack/react-query'
<<<<<<< Updated upstream
import {useAnalytics} from '#/analytics'
=======
>>>>>>> Stashed changes
import {
GIF_FEATURED,
GIF_KLIPY_FEATURED,
@@ -10,6 +13,7 @@ import {
GIF_SEARCH,
} from '#/lib/constants'
import {logger} from '#/logger'
import {useAnalytics} from '#/analytics'
export const RQKEY_ROOT = 'gif-service'
export const RQKEY_FEATURED = (provider: string) => [
@@ -130,9 +134,14 @@ export function tenorUrlToBskyGifUrl(tenorUrl: string) {
}
/**
<<<<<<< Updated upstream
* Returns the appropriate static URL for a GIF preview image.
* For Tenor URLs, rewrites through the bsky proxy.
* For KLIPY URLs, returns as-is (no proxy yet).
=======
* Returns the appropriate URL for a GIF preview image.
* Rewrites Tenor URLs through the bsky proxy; KLIPY URLs pass through directly.
>>>>>>> Stashed changes
*/
export function gifPreviewUrl(gifUrl: string) {
try {
@@ -140,7 +149,10 @@ export function gifPreviewUrl(gifUrl: string) {
if (url.hostname === 'media.tenor.com') {
return tenorUrlToBskyGifUrl(gifUrl)
}
<<<<<<< Updated upstream
// KLIPY static URLs and others pass through directly
=======
>>>>>>> Stashed changes
return gifUrl
} catch (e) {
logger.debug('invalid url passed to gifPreviewUrl()')
+2 -1
View File
@@ -26,6 +26,7 @@ import {type DraftPostDisplay, type DraftSummary} from './schema'
import * as storage from './storage'
const TENOR_HOSTNAME = 'media.tenor.com'
const KLIPY_HOSTNAME = 'static.klipy.com'
/**
* Video data from a draft that needs to be restored by re-processing.
@@ -379,7 +380,7 @@ function parseGifFromUrl(
): {url: string; width: number; height: number; alt: string} | undefined {
try {
const url = new URL(uri)
if (url.hostname !== TENOR_HOSTNAME) {
if (url.hostname !== TENOR_HOSTNAME && url.hostname !== KLIPY_HOSTNAME) {
return undefined
}