From c0ca891501cbc60eb945e3235800ec1e29a15ccd Mon Sep 17 00:00:00 2001
From: Hailey <me@haileyok.com>
Date: Fri, 19 Apr 2024 15:31:20 -0700
Subject: Player improvement pre-reqs (#3618)

* add dims to type

* save

* add the dimensions to the embed info

* add a new case

* add a new case

* limit this case to giphy

* use gate

* flip mp4/webp

* fix tests

* add new test
---
 .../com/util/post-embeds/ExternalLinkEmbed.tsx     | 47 +++++++++++++---------
 1 file changed, 29 insertions(+), 18 deletions(-)

(limited to 'src/view/com/util/post-embeds/ExternalLinkEmbed.tsx')

diff --git a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx
index aaa98a41f..ff7c643f6 100644
--- a/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx
+++ b/src/view/com/util/post-embeds/ExternalLinkEmbed.tsx
@@ -1,15 +1,17 @@
 import React from 'react'
-import {Image} from 'expo-image'
-import {Text} from '../text/Text'
 import {StyleSheet, View} from 'react-native'
+import {Image} from 'expo-image'
+import {AppBskyEmbedExternal} from '@atproto/api'
+
 import {usePalette} from 'lib/hooks/usePalette'
 import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
-import {AppBskyEmbedExternal} from '@atproto/api'
-import {toNiceDomain} from 'lib/strings/url-helpers'
+import {useGate} from 'lib/statsig/statsig'
 import {parseEmbedPlayerFromUrl} from 'lib/strings/embed-player'
-import {ExternalPlayer} from 'view/com/util/post-embeds/ExternalPlayerEmbed'
-import {ExternalGifEmbed} from 'view/com/util/post-embeds/ExternalGifEmbed'
+import {toNiceDomain} from 'lib/strings/url-helpers'
 import {useExternalEmbedsPrefs} from 'state/preferences'
+import {ExternalGifEmbed} from 'view/com/util/post-embeds/ExternalGifEmbed'
+import {ExternalPlayer} from 'view/com/util/post-embeds/ExternalPlayerEmbed'
+import {Text} from '../text/Text'
 
 export const ExternalLinkEmbed = ({
   link,
@@ -19,6 +21,7 @@ export const ExternalLinkEmbed = ({
   const pal = usePalette('default')
   const {isMobile} = useWebMediaQueries()
   const externalEmbedPrefs = useExternalEmbedsPrefs()
+  const gate = useGate()
 
   const embedPlayerParams = React.useMemo(() => {
     const params = parseEmbedPlayerFromUrl(link.uri)
@@ -27,6 +30,10 @@ export const ExternalLinkEmbed = ({
       return params
     }
   }, [link.uri, externalEmbedPrefs])
+  const isCompatibleGiphy =
+    embedPlayerParams?.source === 'giphy' &&
+    embedPlayerParams.dimensions &&
+    gate('new_gif_player')
 
   return (
     <View style={styles.container}>
@@ -37,20 +44,24 @@ export const ExternalLinkEmbed = ({
           accessibilityIgnoresInvertColors
         />
       ) : undefined}
-      {(embedPlayerParams?.isGif && (
+      {isCompatibleGiphy ? (
+        <View />
+      ) : embedPlayerParams?.isGif ? (
         <ExternalGifEmbed link={link} params={embedPlayerParams} />
-      )) ||
-        (embedPlayerParams && (
-          <ExternalPlayer link={link} params={embedPlayerParams} />
-        ))}
+      ) : embedPlayerParams ? (
+        <ExternalPlayer link={link} params={embedPlayerParams} />
+      ) : undefined}
       <View style={[styles.info, {paddingHorizontal: isMobile ? 10 : 14}]}>
-        <Text
-          type="sm"
-          numberOfLines={1}
-          style={[pal.textLight, styles.extUri]}>
-          {toNiceDomain(link.uri)}
-        </Text>
-        {!embedPlayerParams?.isGif && (
+        {!isCompatibleGiphy && (
+          <Text
+            type="sm"
+            numberOfLines={1}
+            style={[pal.textLight, styles.extUri]}>
+            {toNiceDomain(link.uri)}
+          </Text>
+        )}
+
+        {!embedPlayerParams?.isGif && !embedPlayerParams?.dimensions && (
           <Text type="lg-bold" numberOfLines={3} style={[pal.text]}>
             {link.title || link.uri}
           </Text>
-- 
cgit 1.4.1

