Skip to content

Commit

Permalink
tweaks to constants (#7478)
Browse files Browse the repository at this point in the history
* add did

* use correct did

* typo

* tweak
  • Loading branch information
haileyok authored Jan 17, 2025
1 parent ec9cafd commit 6f3f116
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
15 changes: 15 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ export function IS_PROD_SERVICE(url?: string) {
export const PROD_DEFAULT_FEED = (rkey: string) =>
`at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/${rkey}`

export const STAGING_DEFAULT_FEED = (rkey: string) =>
`at://did:plc:yofh3kx63drvfljkibw5zuxo/app.bsky.feed.generator/${rkey}`

export const PROD_FEEDS = [
`feedgen|${PROD_DEFAULT_FEED('whats-hot')}`,
`feedgen|${PROD_DEFAULT_FEED('thevids')}`,
]

export const STAGING_FEEDS = [
`feedgen|${STAGING_DEFAULT_FEED('whats-hot')}`,
`feedgen|${STAGING_DEFAULT_FEED('thevids')}`,
]

export const FEEDBACK_FEEDS = [...PROD_FEEDS, ...STAGING_FEEDS]

export const POST_IMG_MAX = {
width: 2000,
height: 2000,
Expand Down
14 changes: 10 additions & 4 deletions src/state/feed-feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {AppState, AppStateStatus} from 'react-native'
import {AppBskyFeedDefs} from '@atproto/api'
import throttle from 'lodash.throttle'

import {PROD_DEFAULT_FEED} from '#/lib/constants'
import {FEEDBACK_FEEDS, STAGING_FEEDS} from '#/lib/constants'
import {logEvent} from '#/lib/statsig/statsig'
import {logger} from '#/logger'
import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed'
Expand All @@ -25,6 +25,7 @@ const stateContext = React.createContext<StateContext>({
export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
const agent = useAgent()
const enabled = isDiscoverFeed(feed) && hasSession

const queue = React.useRef<Set<string>>(new Set())
const history = React.useRef<
// Use a WeakSet so that we don't need to clear it.
Expand All @@ -46,6 +47,11 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
const interactions = Array.from(queue.current).map(toInteraction)
queue.current.clear()

let proxyDid = 'did:web:discover.bsky.app'
if (STAGING_FEEDS.includes(feed)) {
proxyDid = 'did:web:algo.pop2.bsky.app'
}

// Send to the feed
agent.app.bsky.feed
.sendInteractions(
Expand All @@ -54,7 +60,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
encoding: 'application/json',
headers: {
// TODO when we start sending to other feeds, we need to grab their DID -prf
'atproto-proxy': 'did:web:discover.bsky.app#bsky_fg',
'atproto-proxy': `${proxyDid}#bsky_fg`,
},
},
)
Expand All @@ -68,7 +74,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
}
sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions)
throttledFlushAggregatedStats()
}, [agent, throttledFlushAggregatedStats])
}, [agent, throttledFlushAggregatedStats, feed])

const sendToFeed = React.useMemo(
() =>
Expand Down Expand Up @@ -155,7 +161,7 @@ export function useFeedFeedbackContext() {
// place, we're hardcoding it to the discover feed.
// -prf
function isDiscoverFeed(feed: FeedDescriptor) {
return feed === `feedgen|${PROD_DEFAULT_FEED('whats-hot')}`
return FEEDBACK_FEEDS.includes(feed)
}

function toString(interaction: AppBskyFeedDefs.Interaction): string {
Expand Down

0 comments on commit 6f3f116

Please sign in to comment.