about summary refs log tree commit diff
path: root/src/components/PostControls/DiscoverDebug.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/PostControls/DiscoverDebug.tsx')
-rw-r--r--src/components/PostControls/DiscoverDebug.tsx54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/components/PostControls/DiscoverDebug.tsx b/src/components/PostControls/DiscoverDebug.tsx
new file mode 100644
index 000000000..796981f0c
--- /dev/null
+++ b/src/components/PostControls/DiscoverDebug.tsx
@@ -0,0 +1,54 @@
+import {Pressable} from 'react-native'
+import * as Clipboard from 'expo-clipboard'
+import {t} from '@lingui/macro'
+
+import {IS_INTERNAL} from '#/lib/app-info'
+import {DISCOVER_DEBUG_DIDS} from '#/lib/constants'
+import {useGate} from '#/lib/statsig/statsig'
+import {useSession} from '#/state/session'
+import * as Toast from '#/view/com/util/Toast'
+import {atoms as a, useBreakpoints, useTheme} from '#/alf'
+import {Text} from '#/components/Typography'
+
+export function DiscoverDebug({
+  feedContext,
+}: {
+  feedContext: string | undefined
+}) {
+  const {currentAccount} = useSession()
+  const {gtMobile} = useBreakpoints()
+  const gate = useGate()
+  const isDiscoverDebugUser =
+    IS_INTERNAL ||
+    DISCOVER_DEBUG_DIDS[currentAccount?.did || ''] ||
+    gate('debug_show_feedcontext')
+  const theme = useTheme()
+
+  return (
+    isDiscoverDebugUser &&
+    feedContext && (
+      <Pressable
+        accessible={false}
+        hitSlop={10}
+        style={[
+          a.absolute,
+          a.bottom_0,
+          {zIndex: 1000},
+          gtMobile ? a.right_0 : a.left_0,
+        ]}
+        onPress={e => {
+          e.stopPropagation()
+          Clipboard.setStringAsync(feedContext)
+          Toast.show(t`Copied to clipboard`, 'clipboard-check')
+        }}>
+        <Text
+          style={{
+            color: theme.palette.contrast_400,
+            fontSize: 7,
+          }}>
+          {feedContext}
+        </Text>
+      </Pressable>
+    )
+  )
+}