Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into ko-kr
Browse files Browse the repository at this point in the history
  • Loading branch information
quiple committed Dec 28, 2024
2 parents 83d274c + c6d26a0 commit 27b1726
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 34 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-native-fontawesome": "^0.3.2",
"@haileyok/bluesky-video": "0.2.5",
"@haileyok/bluesky-video": "0.2.6",
"@ipld/dag-cbor": "^9.2.0",
"@lingui/react": "^4.14.1",
"@mattermost/react-native-paste-input": "^0.7.1",
Expand Down
6 changes: 5 additions & 1 deletion src/components/ProgressGuide/FollowDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
import {logEvent} from '#/lib/statsig/statsig'
import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger'
import {isWeb} from '#/platform/detection'
Expand Down Expand Up @@ -75,7 +76,10 @@ export function FollowDialog({guide}: {guide: Follow10ProgressGuide}) {
<>
<Button
label={_(msg`Find people to follow`)}
onPress={control.open}
onPress={() => {
control.open()
logEvent('progressGuide:followDialog:open', {})
}}
size={gtMobile ? 'small' : 'large'}
color="primary"
variant="solid">
Expand Down
7 changes: 6 additions & 1 deletion src/components/interstitials/Trending.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ export function Inner() {
) : !trending?.topics ? null : (
<>
{trending.topics.map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}>
<TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('trendingTopic:click', {context: 'interstitial'})
}}>
{({hovered}) => (
<TrendingTopic
topic={topic}
Expand Down
15 changes: 13 additions & 2 deletions src/lib/statsig/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,19 @@ export type LogEvents = {
'tmd:download': {}
'tmd:post': {}

'trendingTopics:show': {}
'trendingTopics:show': {
context: 'settings'
}
'trendingTopics:hide': {
context: 'sidebar' | 'interstitial' | 'explore:trending'
context: 'settings' | 'sidebar' | 'interstitial' | 'explore:trending'
}
'trendingTopic:click': {
context: 'sidebar' | 'interstitial' | 'explore'
}
'recommendedTopic:click': {
context: 'explore'
}

'progressGuide:hide': {}
'progressGuide:followDialog:open': {}
}
8 changes: 7 additions & 1 deletion src/screens/Search/components/ExploreRecommendations.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {View} from 'react-native'
import {Trans} from '@lingui/macro'

import {logEvent} from '#/lib/statsig/statsig'
import {isWeb} from '#/platform/detection'
import {
DEFAULT_LIMIT as RECOMMENDATIONS_COUNT,
Expand Down Expand Up @@ -71,7 +72,12 @@ function Inner() {
) : !trending?.suggested ? null : (
<>
{trending.suggested.map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}>
<TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('recommendedTopic:click', {context: 'explore'})
}}>
{({hovered}) => (
<TrendingTopic
topic={topic}
Expand Down
7 changes: 6 additions & 1 deletion src/screens/Search/components/ExploreTrendingTopics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ function Inner() {
) : !trending?.topics ? null : (
<>
{trending.topics.map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}>
<TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('trendingTopic:click', {context: 'explore'})
}}>
{({hovered}) => (
<TrendingTopic
topic={topic}
Expand Down
11 changes: 10 additions & 1 deletion src/screens/Settings/ContentAndMediaSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useLingui} from '@lingui/react'
import {NativeStackScreenProps} from '@react-navigation/native-stack'

import {CommonNavigatorParams} from '#/lib/routes/types'
import {logEvent} from '#/lib/statsig/statsig'
import {isNative} from '#/platform/detection'
import {useAutoplayDisabled, useSetAutoplayDisabled} from '#/state/preferences'
import {
Expand Down Expand Up @@ -120,7 +121,15 @@ export function ContentAndMediaSettingsScreen({}: Props) {
name="show_trending_topics"
label={_(msg`Enable trending topics`)}
value={!trendingDisabled}
onChange={value => setTrendingDisabled(!value)}>
onChange={value => {
const hide = Boolean(!value)
if (hide) {
logEvent('trendingTopics:hide', {context: 'settings'})
} else {
logEvent('trendingTopics:show', {context: 'settings'})
}
setTrendingDisabled(hide)
}}>
<SettingsList.Item>
<SettingsList.ItemIcon icon={Graph} />
<SettingsList.ItemText>
Expand Down
7 changes: 1 addition & 6 deletions src/state/preferences/trending.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'

import {logEvent} from '#/lib/statsig/statsig'
import * as persisted from '#/state/persisted'

type StateContext = {
Expand All @@ -27,11 +26,7 @@ function usePersistedBooleanValue<T extends keyof persisted.Schema>(key: T) {
(value: Exclude<persisted.Schema[T], undefined>) => void
>(
hidden => {
const hide = Boolean(hidden)
if (!hide) {
logEvent('trendingTopics:show', {})
}
_set(hide)
_set(Boolean(hidden))
persisted.write(key, hidden)
},
[key, _set],
Expand Down
42 changes: 27 additions & 15 deletions src/state/queries/trending/useTrendingTopics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import {useAgent} from '#/state/session'

export type TrendingTopic = AppBskyUnspeccedDefs.TrendingTopic

type Response = {
topics: TrendingTopic[]
suggested: TrendingTopic[]
}

export const DEFAULT_LIMIT = 14

export const trendingTopicsQueryKey = ['trending-topics']
Expand All @@ -20,30 +25,37 @@ export function useTrendingTopics() {
return preferences?.moderationPrefs?.mutedWords || []
}, [preferences?.moderationPrefs])

return useQuery({
return useQuery<Response>({
refetchOnWindowFocus: true,
staleTime: STALE.MINUTES.THREE,
queryKey: trendingTopicsQueryKey,
async queryFn() {
const {data} = await agent.api.app.bsky.unspecced.getTrendingTopics({
limit: DEFAULT_LIMIT,
})

const {topics, suggested} = data
return {
topics: topics.filter(t => {
return !hasMutedWord({
mutedWords,
text: t.topic + ' ' + t.displayName + ' ' + t.description,
})
}),
suggested: suggested.filter(t => {
return !hasMutedWord({
mutedWords,
text: t.topic + ' ' + t.displayName + ' ' + t.description,
})
}),
topics: data.topics ?? [],
suggested: data.suggested ?? [],
}
},
select: React.useCallback(
(data: Response) => {
return {
topics: data.topics.filter(t => {
return !hasMutedWord({
mutedWords,
text: t.topic + ' ' + t.displayName + ' ' + t.description,
})
}),
suggested: data.suggested.filter(t => {
return !hasMutedWord({
mutedWords,
text: t.topic + ' ' + t.displayName + ' ' + t.description,
})
}),
}
},
[mutedWords],
),
})
}
2 changes: 2 additions & 0 deletions src/state/shell/progress-guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {useMemo} from 'react'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {logEvent} from '#/lib/statsig/statsig'
import {
ProgressGuideToast,
ProgressGuideToastRef,
Expand Down Expand Up @@ -137,6 +138,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
endProgressGuide() {
setLocalGuideState(undefined)
mutateAsync(undefined)
logEvent('progressGuide:hide', {})
},

captureAction(action: ProgressGuideAction, count = 1) {
Expand Down
7 changes: 6 additions & 1 deletion src/view/shell/desktop/SidebarTrendingTopics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ function Inner() {
) : !trending?.topics ? null : (
<>
{trending.topics.slice(0, TRENDING_LIMIT).map(topic => (
<TrendingTopicLink key={topic.link} topic={topic}>
<TrendingTopicLink
key={topic.link}
topic={topic}
onPress={() => {
logEvent('trendingTopic:click', {context: 'sidebar'})
}}>
{({hovered}) => (
<TrendingTopic
size="small"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4295,10 +4295,10 @@
dependencies:
nanoid "^3.3.1"

"@haileyok/[email protected].5":
version "0.2.5"
resolved "https://registry.yarnpkg.com/@haileyok/bluesky-video/-/bluesky-video-0.2.5.tgz#eb05f21b5eeef151045b047b39e77df8628a6b3f"
integrity sha512-PIH2jXLi32z56eNgQprhBC+8Czo8kogcy0TIrncMDF82e/yftqv8vL/OyMDLCifavlVtl/h5tEQzt4Q4PJyv2A==
"@haileyok/[email protected].6":
version "0.2.6"
resolved "https://registry.yarnpkg.com/@haileyok/bluesky-video/-/bluesky-video-0.2.6.tgz#61bb4ff908498558fd2320f06ba0f74ea03598b4"
integrity sha512-IlzrTATD7ci/a+ehSA7pIhOvxxNTe35zdzBYt8EmVvKKafyeFhxGfDuuP5qxfQmHurcQMIL+3HeZgnAXwQQNmQ==

"@hapi/accept@^6.0.3":
version "6.0.3"
Expand Down

0 comments on commit 27b1726

Please sign in to comment.