From 5e78c947a0853792900f76d17bd9468983ad51b6 Mon Sep 17 00:00:00 2001
From: Samuel Newman <mozzius@protonmail.com>
Date: Mon, 15 Sep 2025 13:02:37 +0300
Subject: Add missing passive feed interactions (#9043)

---
 src/state/feed-feedback.tsx | 53 ++++++++++-----------------------------------
 1 file changed, 11 insertions(+), 42 deletions(-)

(limited to 'src/state/feed-feedback.tsx')

diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx
index 3e9c2bafa..88d9a47d0 100644
--- a/src/state/feed-feedback.tsx
+++ b/src/state/feed-feedback.tsx
@@ -28,39 +28,9 @@ import {useAgent} from './session'
 
 export const FEEDBACK_FEEDS = [...PROD_FEEDS, ...STAGING_FEEDS]
 
-export const PASSIVE_FEEDBACK_INTERACTIONS = [
-  'app.bsky.feed.defs#clickthroughItem',
-  'app.bsky.feed.defs#clickthroughAuthor',
-  'app.bsky.feed.defs#clickthroughReposter',
-  'app.bsky.feed.defs#clickthroughEmbed',
-  'app.bsky.feed.defs#interactionSeen',
-] as const
-
-export type PassiveFeedbackInteraction =
-  (typeof PASSIVE_FEEDBACK_INTERACTIONS)[number]
-
-export const DIRECT_FEEDBACK_INTERACTIONS = [
-  'app.bsky.feed.defs#requestLess',
-  'app.bsky.feed.defs#requestMore',
-] as const
-
-export type DirectFeedbackInteraction =
-  (typeof DIRECT_FEEDBACK_INTERACTIONS)[number]
-
-export const ALL_FEEDBACK_INTERACTIONS = [
-  ...PASSIVE_FEEDBACK_INTERACTIONS,
-  ...DIRECT_FEEDBACK_INTERACTIONS,
-] as const
-
-export type FeedbackInteraction = (typeof ALL_FEEDBACK_INTERACTIONS)[number]
-
-export function isFeedbackInteraction(
-  interactionEvent: string,
-): interactionEvent is FeedbackInteraction {
-  return ALL_FEEDBACK_INTERACTIONS.includes(
-    interactionEvent as FeedbackInteraction,
-  )
-}
+export const DIRECT_FEEDBACK_INTERACTIONS = new Set<
+  AppBskyFeedDefs.Interaction['event']
+>(['app.bsky.feed.defs#requestLess', 'app.bsky.feed.defs#requestMore'])
 
 const logger = Logger.create(Logger.Context.FeedFeedback)
 
@@ -97,7 +67,6 @@ export function useFeedFeedback(
   const proxyDid = feed?.view?.did
   const enabled =
     Boolean(feed) && Boolean(proxyDid) && acceptsInteractions && hasSession
-  const enabledInteractions = getEnabledInteractions(enabled, feed, isDiscover)
 
   const queue = useRef<Set<string>>(new Set())
   const history = useRef<
@@ -123,8 +92,7 @@ export function useFeedFeedback(
     const interactionsToSend = interactions.filter(
       interaction =>
         interaction.event &&
-        isFeedbackInteraction(interaction.event) &&
-        enabledInteractions.includes(interaction.event),
+        isInteractionAllowed(enabled, feed, interaction.event),
     )
 
     if (interactionsToSend.length === 0) {
@@ -158,7 +126,7 @@ export function useFeedFeedback(
     )
     throttledFlushAggregatedStats()
     logger.debug('flushed')
-  }, [agent, throttledFlushAggregatedStats, proxyDid, enabledInteractions])
+  }, [agent, throttledFlushAggregatedStats, proxyDid, enabled, feed])
 
   const sendToFeed = useMemo(
     () =>
@@ -251,15 +219,16 @@ export function isDiscoverFeed(feed?: FeedDescriptor) {
   return !!feed && FEEDBACK_FEEDS.includes(feed)
 }
 
-function getEnabledInteractions(
+function isInteractionAllowed(
   enabled: boolean,
   feed: FeedSourceFeedInfo | undefined,
-  isDiscover: boolean,
-): readonly FeedbackInteraction[] {
+  interaction: AppBskyFeedDefs.Interaction['event'],
+) {
   if (!enabled || !feed) {
-    return []
+    return false
   }
-  return isDiscover ? ALL_FEEDBACK_INTERACTIONS : DIRECT_FEEDBACK_INTERACTIONS
+  const isDiscover = isDiscoverFeed(feed.feedDescriptor)
+  return isDiscover ? true : DIRECT_FEEDBACK_INTERACTIONS.has(interaction)
 }
 
 function toString(interaction: AppBskyFeedDefs.Interaction): string {
-- 
cgit 1.4.1

