wip v2
This commit is contained in:
@@ -15,6 +15,7 @@ import {Trans} from '@lingui/react/macro'
|
|||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {
|
import {
|
||||||
type Gif,
|
type Gif,
|
||||||
|
<<<<<<< Updated upstream
|
||||||
klipyStaticUrl,
|
klipyStaticUrl,
|
||||||
useFeaturedGifsQuery as useKlipyFeaturedGifsQuery,
|
useFeaturedGifsQuery as useKlipyFeaturedGifsQuery,
|
||||||
useGifSearchQuery as useKlipyGifSearchQuery,
|
useGifSearchQuery as useKlipyGifSearchQuery,
|
||||||
@@ -22,6 +23,11 @@ import {
|
|||||||
import {
|
import {
|
||||||
useTenorFeaturedGifsQuery,
|
useTenorFeaturedGifsQuery,
|
||||||
useTenorGifSearchQuery,
|
useTenorGifSearchQuery,
|
||||||
|
=======
|
||||||
|
gifPreviewUrl,
|
||||||
|
useFeaturedGifsQuery,
|
||||||
|
useGifSearchQuery,
|
||||||
|
>>>>>>> Stashed changes
|
||||||
} 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'
|
||||||
@@ -98,6 +104,7 @@ function GifList({
|
|||||||
const [undeferredSearch, setSearch] = useState('')
|
const [undeferredSearch, setSearch] = useState('')
|
||||||
const search = useThrottledValue(undeferredSearch, 500)
|
const search = useThrottledValue(undeferredSearch, 500)
|
||||||
const {height} = useWindowDimensions()
|
const {height} = useWindowDimensions()
|
||||||
|
const useKlipy = ax.features.enabled(ax.features.KlipyGifProviderEnable)
|
||||||
|
|
||||||
const isSearching = search.length > 0
|
const isSearching = search.length > 0
|
||||||
const useKlipy = ax.features.enabled(ax.features.KlipyGifProviderEnable)
|
const useKlipy = ax.features.enabled(ax.features.KlipyGifProviderEnable)
|
||||||
@@ -332,7 +339,11 @@ export function GifPreview({
|
|||||||
t.atoms.bg_contrast_25,
|
t.atoms.bg_contrast_25,
|
||||||
]}
|
]}
|
||||||
source={{
|
source={{
|
||||||
|
<<<<<<< Updated upstream
|
||||||
uri: klipyStaticUrl(gif.file.sm.gif.url),
|
uri: klipyStaticUrl(gif.file.sm.gif.url),
|
||||||
|
=======
|
||||||
|
uri: gifPreviewUrl(gif.media_formats.tinygif.url),
|
||||||
|
>>>>>>> Stashed changes
|
||||||
}}
|
}}
|
||||||
contentFit="cover"
|
contentFit="cover"
|
||||||
accessibilityLabel={gif.title}
|
accessibilityLabel={gif.title}
|
||||||
|
|||||||
@@ -191,11 +191,12 @@ export async function resolveGif(
|
|||||||
gif: Gif,
|
gif: Gif,
|
||||||
): Promise<ResolvedExternalLink> {
|
): Promise<ResolvedExternalLink> {
|
||||||
const uri = `${gif.media_formats.gif.url}?hh=${gif.media_formats.gif.dims[1]}&ww=${gif.media_formats.gif.dims[0]}`
|
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 {
|
return {
|
||||||
type: 'external',
|
type: 'external',
|
||||||
uri,
|
uri,
|
||||||
title: gif.content_description,
|
title: altText,
|
||||||
description: createGIFDescription(gif.content_description),
|
description: createGIFDescription(altText),
|
||||||
thumb: await imageToThumb(gif.media_formats.preview.url),
|
thumb: await imageToThumb(gif.media_formats.preview.url),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ import {Platform} from 'react-native'
|
|||||||
import {getLocales} from 'expo-localization'
|
import {getLocales} from 'expo-localization'
|
||||||
import {keepPreviousData, useInfiniteQuery} from '@tanstack/react-query'
|
import {keepPreviousData, useInfiniteQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
<<<<<<< Updated upstream
|
||||||
import {useAnalytics} from '#/analytics'
|
import {useAnalytics} from '#/analytics'
|
||||||
|
=======
|
||||||
|
>>>>>>> Stashed changes
|
||||||
import {
|
import {
|
||||||
GIF_FEATURED,
|
GIF_FEATURED,
|
||||||
GIF_KLIPY_FEATURED,
|
GIF_KLIPY_FEATURED,
|
||||||
@@ -10,6 +13,7 @@ import {
|
|||||||
GIF_SEARCH,
|
GIF_SEARCH,
|
||||||
} from '#/lib/constants'
|
} from '#/lib/constants'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
|
import {useAnalytics} from '#/analytics'
|
||||||
|
|
||||||
export const RQKEY_ROOT = 'gif-service'
|
export const RQKEY_ROOT = 'gif-service'
|
||||||
export const RQKEY_FEATURED = (provider: string) => [
|
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.
|
* Returns the appropriate static URL for a GIF preview image.
|
||||||
* For Tenor URLs, rewrites through the bsky proxy.
|
* For Tenor URLs, rewrites through the bsky proxy.
|
||||||
* For KLIPY URLs, returns as-is (no proxy yet).
|
* 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) {
|
export function gifPreviewUrl(gifUrl: string) {
|
||||||
try {
|
try {
|
||||||
@@ -140,7 +149,10 @@ export function gifPreviewUrl(gifUrl: string) {
|
|||||||
if (url.hostname === 'media.tenor.com') {
|
if (url.hostname === 'media.tenor.com') {
|
||||||
return tenorUrlToBskyGifUrl(gifUrl)
|
return tenorUrlToBskyGifUrl(gifUrl)
|
||||||
}
|
}
|
||||||
|
<<<<<<< Updated upstream
|
||||||
// KLIPY static URLs and others pass through directly
|
// KLIPY static URLs and others pass through directly
|
||||||
|
=======
|
||||||
|
>>>>>>> Stashed changes
|
||||||
return gifUrl
|
return gifUrl
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.debug('invalid url passed to gifPreviewUrl()')
|
logger.debug('invalid url passed to gifPreviewUrl()')
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {type DraftPostDisplay, type DraftSummary} from './schema'
|
|||||||
import * as storage from './storage'
|
import * as storage from './storage'
|
||||||
|
|
||||||
const TENOR_HOSTNAME = 'media.tenor.com'
|
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.
|
* 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 {
|
): {url: string; width: number; height: number; alt: string} | undefined {
|
||||||
try {
|
try {
|
||||||
const url = new URL(uri)
|
const url = new URL(uri)
|
||||||
if (url.hostname !== TENOR_HOSTNAME) {
|
if (url.hostname !== TENOR_HOSTNAME && url.hostname !== KLIPY_HOSTNAME) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user