diff --git a/src/components/dialogs/GifSelect.tsx b/src/components/dialogs/GifSelect.tsx index e92c461450..a939f4ab2d 100644 --- a/src/components/dialogs/GifSelect.tsx +++ b/src/components/dialogs/GifSelect.tsx @@ -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} diff --git a/src/lib/api/resolve.ts b/src/lib/api/resolve.ts index 0424876767..5ce0d70971 100644 --- a/src/lib/api/resolve.ts +++ b/src/lib/api/resolve.ts @@ -191,11 +191,12 @@ export async function resolveGif( gif: Gif, ): Promise { 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), } } diff --git a/src/state/queries/tenor.ts b/src/state/queries/tenor.ts index c6de07dae5..9522a801e0 100644 --- a/src/state/queries/tenor.ts +++ b/src/state/queries/tenor.ts @@ -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()') diff --git a/src/view/com/composer/drafts/state/api.ts b/src/view/com/composer/drafts/state/api.ts index 97ba95d2bd..c09112e8c3 100644 --- a/src/view/com/composer/drafts/state/api.ts +++ b/src/view/com/composer/drafts/state/api.ts @@ -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 }