Getting started logic now checks net follow count instead of total follow events
This commit is contained in:
committed by
Samuel Newman
parent
6bcb5236d9
commit
599e92861d
@@ -32,7 +32,6 @@ import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
|||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
||||||
import {MagnifyingGlass_Stroke2_Corner0_Rounded as SearchIcon} from '#/components/icons/MagnifyingGlass'
|
import {MagnifyingGlass_Stroke2_Corner0_Rounded as SearchIcon} from '#/components/icons/MagnifyingGlass'
|
||||||
import {PersonGroup_Stroke2_Corner2_Rounded as PersonGroupIcon} from '#/components/icons/Person'
|
|
||||||
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'
|
||||||
import {boostInterests, InterestTabs} from '#/components/InterestTabs'
|
import {boostInterests, InterestTabs} from '#/components/InterestTabs'
|
||||||
import * as ProfileCard from '#/components/ProfileCard'
|
import * as ProfileCard from '#/components/ProfileCard'
|
||||||
@@ -77,7 +76,6 @@ export function FollowDialog({guide}: {guide: Follow10ProgressGuide}) {
|
|||||||
size={gtMobile ? 'small' : 'large'}
|
size={gtMobile ? 'small' : 'large'}
|
||||||
color="primary"
|
color="primary"
|
||||||
variant="solid">
|
variant="solid">
|
||||||
<ButtonIcon icon={PersonGroupIcon} />
|
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Find people to follow</Trans>
|
<Trans>Find people to follow</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
|
|||||||
@@ -2,24 +2,41 @@ import {type StyleProp, View, type ViewStyle} from 'react-native'
|
|||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {useProfileFollowsQuery} from '#/state/queries/profile-follows'
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
import {
|
import {
|
||||||
useProgressGuide,
|
useProgressGuide,
|
||||||
useProgressGuideControls,
|
useProgressGuideControls,
|
||||||
} from '#/state/shell/progress-guide'
|
} from '#/state/shell/progress-guide'
|
||||||
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {Button, ButtonIcon} from '#/components/Button'
|
import {Button, ButtonIcon} from '#/components/Button'
|
||||||
|
import {Person_Stroke2_Corner2_Rounded as PersonIcon} from '#/components/icons/Person'
|
||||||
import {TimesLarge_Stroke2_Corner0_Rounded as Times} from '#/components/icons/Times'
|
import {TimesLarge_Stroke2_Corner0_Rounded as Times} from '#/components/icons/Times'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {FollowDialog} from './FollowDialog'
|
import {FollowDialog} from './FollowDialog'
|
||||||
import {ProgressGuideTask} from './Task'
|
import {ProgressGuideTask} from './Task'
|
||||||
|
|
||||||
|
const TOTAL_AVATARS = 10
|
||||||
|
|
||||||
export function ProgressGuideList({style}: {style?: StyleProp<ViewStyle>}) {
|
export function ProgressGuideList({style}: {style?: StyleProp<ViewStyle>}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
const followProgressGuide = useProgressGuide('follow-10')
|
const followProgressGuide = useProgressGuide('follow-10')
|
||||||
const followAndLikeProgressGuide = useProgressGuide('like-10-and-follow-7')
|
const followAndLikeProgressGuide = useProgressGuide('like-10-and-follow-7')
|
||||||
const guide = followProgressGuide || followAndLikeProgressGuide
|
const guide = followProgressGuide || followAndLikeProgressGuide
|
||||||
const {endProgressGuide} = useProgressGuideControls()
|
const {endProgressGuide} = useProgressGuideControls()
|
||||||
|
const {data: follows} = useProfileFollowsQuery(currentAccount?.did, {
|
||||||
|
limit: TOTAL_AVATARS,
|
||||||
|
})
|
||||||
|
|
||||||
|
const actualFollowsCount = follows?.pages?.[0]?.follows?.length ?? 0
|
||||||
|
|
||||||
|
// Hide if user already follows 10+ people
|
||||||
|
if (guide?.guide === 'follow-10' && actualFollowsCount >= TOTAL_AVATARS) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
if (guide) {
|
if (guide) {
|
||||||
return (
|
return (
|
||||||
@@ -36,9 +53,8 @@ export function ProgressGuideList({style}: {style?: StyleProp<ViewStyle>}) {
|
|||||||
a.pl_md,
|
a.pl_md,
|
||||||
]}>
|
]}>
|
||||||
<View style={[a.flex_row, a.align_center, a.justify_between]}>
|
<View style={[a.flex_row, a.align_center, a.justify_between]}>
|
||||||
<Text
|
<Text style={[t.atoms.text, a.font_semi_bold, a.text_md]}>
|
||||||
style={[t.atoms.text_contrast_medium, a.font_semi_bold, a.text_sm]}>
|
<Trans>Follow 10 people to get started</Trans>
|
||||||
<Trans>Getting Started</Trans>
|
|
||||||
</Text>
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@@ -53,12 +69,7 @@ export function ProgressGuideList({style}: {style?: StyleProp<ViewStyle>}) {
|
|||||||
</View>
|
</View>
|
||||||
{guide.guide === 'follow-10' && (
|
{guide.guide === 'follow-10' && (
|
||||||
<>
|
<>
|
||||||
<ProgressGuideTask
|
<StackedAvatars follows={follows?.pages?.[0]?.follows} />
|
||||||
current={guide.numFollows + 1}
|
|
||||||
total={10 + 1}
|
|
||||||
title={_(msg`Follow 10 accounts`)}
|
|
||||||
subtitle={_(msg`Bluesky is better with friends!`)}
|
|
||||||
/>
|
|
||||||
<FollowDialog guide={guide} />
|
<FollowDialog guide={guide} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@@ -83,3 +94,69 @@ export function ProgressGuideList({style}: {style?: StyleProp<ViewStyle>}) {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function StackedAvatars({follows}: {follows?: {avatar?: string}[]}) {
|
||||||
|
const t = useTheme()
|
||||||
|
const avatarSize = 38
|
||||||
|
const overlap = 11
|
||||||
|
|
||||||
|
// Use actual follows count, not the guide's event counter
|
||||||
|
const followedAvatars = follows?.slice(0, TOTAL_AVATARS) ?? []
|
||||||
|
const remainingSlots = TOTAL_AVATARS - followedAvatars.length
|
||||||
|
|
||||||
|
// Total width calculation: first avatar + (remaining * visible portion)
|
||||||
|
const totalWidth = avatarSize + (TOTAL_AVATARS - 1) * (avatarSize - overlap)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={[a.flex_row, a.self_start, {width: totalWidth}]}>
|
||||||
|
{/* Show followed user avatars */}
|
||||||
|
{followedAvatars.map((follow, i) => (
|
||||||
|
<View
|
||||||
|
key={i}
|
||||||
|
style={[
|
||||||
|
a.rounded_full,
|
||||||
|
{
|
||||||
|
marginLeft: i === 0 ? 0 : -overlap,
|
||||||
|
zIndex: TOTAL_AVATARS - i,
|
||||||
|
borderWidth: 2,
|
||||||
|
borderColor: t.atoms.bg_contrast_25.backgroundColor,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<UserAvatar
|
||||||
|
type="user"
|
||||||
|
size={avatarSize - 4}
|
||||||
|
avatar={follow.avatar}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
{/* Show placeholder avatars for remaining slots */}
|
||||||
|
{Array(remainingSlots)
|
||||||
|
.fill(0)
|
||||||
|
.map((_, i) => (
|
||||||
|
<View
|
||||||
|
key={`placeholder-${i}`}
|
||||||
|
style={[
|
||||||
|
a.align_center,
|
||||||
|
a.justify_center,
|
||||||
|
a.rounded_full,
|
||||||
|
t.atoms.bg_contrast_100,
|
||||||
|
{
|
||||||
|
width: avatarSize,
|
||||||
|
height: avatarSize,
|
||||||
|
marginLeft:
|
||||||
|
followedAvatars.length === 0 && i === 0 ? 0 : -overlap,
|
||||||
|
zIndex: TOTAL_AVATARS - followedAvatars.length - i,
|
||||||
|
borderWidth: 2,
|
||||||
|
borderColor: t.atoms.bg_contrast_25.backgroundColor,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<PersonIcon
|
||||||
|
width={18}
|
||||||
|
height={18}
|
||||||
|
fill={t.atoms.text_contrast_low.color}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {type Shadow} from '#/state/cache/types'
|
|||||||
import {type ImageMeta} from '#/state/gallery'
|
import {type ImageMeta} from '#/state/gallery'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {resetProfilePostsQueries} from '#/state/queries/post-feed'
|
import {resetProfilePostsQueries} from '#/state/queries/post-feed'
|
||||||
|
import {RQKEY as PROFILE_FOLLOWS_RQKEY} from '#/state/queries/profile-follows'
|
||||||
import {
|
import {
|
||||||
unstableCacheProfileView,
|
unstableCacheProfileView,
|
||||||
useUnstableProfileViewCache,
|
useUnstableProfileViewCache,
|
||||||
@@ -247,6 +248,7 @@ export function useProfileFollowMutationQueue(
|
|||||||
) {
|
) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const {currentAccount} = useSession()
|
||||||
const did = profile.did
|
const did = profile.did
|
||||||
const initialFollowingUri = profile.viewer?.following
|
const initialFollowingUri = profile.viewer?.following
|
||||||
const followMutation = useProfileFollowMutation(
|
const followMutation = useProfileFollowMutation(
|
||||||
@@ -283,6 +285,44 @@ export function useProfileFollowMutationQueue(
|
|||||||
followingUri: finalFollowingUri,
|
followingUri: finalFollowingUri,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Optimistically update profile follows cache for avatar displays
|
||||||
|
if (currentAccount?.did) {
|
||||||
|
queryClient.setQueryData(
|
||||||
|
PROFILE_FOLLOWS_RQKEY(currentAccount.did),
|
||||||
|
(old: any) => {
|
||||||
|
if (!old?.pages?.[0]) return old
|
||||||
|
if (finalFollowingUri) {
|
||||||
|
// Add the followed profile to the beginning
|
||||||
|
const alreadyExists = old.pages[0].follows.some(
|
||||||
|
(f: any) => f.did === profile.did,
|
||||||
|
)
|
||||||
|
if (alreadyExists) return old
|
||||||
|
return {
|
||||||
|
...old,
|
||||||
|
pages: [
|
||||||
|
{
|
||||||
|
...old.pages[0],
|
||||||
|
follows: [profile, ...old.pages[0].follows],
|
||||||
|
},
|
||||||
|
...old.pages.slice(1),
|
||||||
|
],
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Remove the unfollowed profile
|
||||||
|
return {
|
||||||
|
...old,
|
||||||
|
pages: old.pages.map((page: any) => ({
|
||||||
|
...page,
|
||||||
|
follows: page.follows.filter(
|
||||||
|
(f: any) => f.did !== profile.did,
|
||||||
|
),
|
||||||
|
})),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (finalFollowingUri) {
|
if (finalFollowingUri) {
|
||||||
agent.app.bsky.graph
|
agent.app.bsky.graph
|
||||||
.getSuggestedFollowsByActor({
|
.getSuggestedFollowsByActor({
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export function DesktopFeeds() {
|
|||||||
* Small padding prevents overflow prior to actually overflowing the
|
* Small padding prevents overflow prior to actually overflowing the
|
||||||
* height of the screen with lots of feeds.
|
* height of the screen with lots of feeds.
|
||||||
*/
|
*/
|
||||||
paddingVertical: 2,
|
paddingTop: 2,
|
||||||
overflowY: 'auto',
|
overflowY: 'auto',
|
||||||
}),
|
}),
|
||||||
]}>
|
]}>
|
||||||
@@ -112,40 +112,50 @@ export function DesktopFeeds() {
|
|||||||
a.self_start,
|
a.self_start,
|
||||||
a.rounded_sm,
|
a.rounded_sm,
|
||||||
{paddingVertical: 6, paddingHorizontal: 8},
|
{paddingVertical: 6, paddingHorizontal: 8},
|
||||||
|
route.name === 'Feeds' && {backgroundColor: t.palette.primary_50},
|
||||||
]}>
|
]}>
|
||||||
{({hovered}) => (
|
{({hovered}) => {
|
||||||
<>
|
const isActive = route.name === 'Feeds'
|
||||||
<View
|
return (
|
||||||
style={[
|
<>
|
||||||
a.align_center,
|
<View
|
||||||
a.justify_center,
|
style={[
|
||||||
a.rounded_xs,
|
a.align_center,
|
||||||
t.atoms.bg_contrast_50,
|
a.justify_center,
|
||||||
{
|
a.rounded_xs,
|
||||||
width: 20,
|
isActive
|
||||||
height: 20,
|
? {backgroundColor: t.palette.primary_100}
|
||||||
},
|
: t.atoms.bg_contrast_50,
|
||||||
]}>
|
{
|
||||||
<Plus
|
width: 20,
|
||||||
style={{width: 16, height: 16}}
|
height: 20,
|
||||||
fill={
|
},
|
||||||
hovered
|
]}>
|
||||||
? t.atoms.text.color
|
<Plus
|
||||||
: t.atoms.text_contrast_medium.color
|
style={{width: 16, height: 16}}
|
||||||
}
|
fill={
|
||||||
/>
|
isActive || hovered
|
||||||
</View>
|
? t.atoms.text.color
|
||||||
<Text
|
: t.atoms.text_contrast_medium.color
|
||||||
style={[
|
}
|
||||||
a.text_md,
|
/>
|
||||||
a.leading_snug,
|
</View>
|
||||||
hovered ? t.atoms.text : t.atoms.text_contrast_medium,
|
<Text
|
||||||
]}
|
style={[
|
||||||
numberOfLines={1}>
|
a.text_md,
|
||||||
{_(msg`More feeds`)}
|
a.leading_snug,
|
||||||
</Text>
|
isActive
|
||||||
</>
|
? [t.atoms.text, a.font_semi_bold]
|
||||||
)}
|
: hovered
|
||||||
|
? t.atoms.text
|
||||||
|
: t.atoms.text_contrast_medium,
|
||||||
|
]}
|
||||||
|
numberOfLines={1}>
|
||||||
|
{_(msg`More feeds`)}
|
||||||
|
</Text>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}}
|
||||||
</Link>
|
</Link>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
@@ -183,7 +193,6 @@ function FeedItem({
|
|||||||
a.self_start,
|
a.self_start,
|
||||||
a.rounded_sm,
|
a.rounded_sm,
|
||||||
{paddingVertical: 6, paddingHorizontal: 8},
|
{paddingVertical: 6, paddingHorizontal: 8},
|
||||||
// current && t.atoms.bg_contrast_50,
|
|
||||||
current && {backgroundColor: t.palette.primary_50},
|
current && {backgroundColor: t.palette.primary_50},
|
||||||
]}>
|
]}>
|
||||||
{isFollowing ? (
|
{isFollowing ? (
|
||||||
|
|||||||
@@ -100,25 +100,31 @@ export function DesktopRightNav({routeName}: {routeName: string}) {
|
|||||||
email: currentAccount?.email,
|
email: currentAccount?.email,
|
||||||
handle: currentAccount?.handle,
|
handle: currentAccount?.handle,
|
||||||
})}
|
})}
|
||||||
|
style={[t.atoms.text_contrast_medium]}
|
||||||
label={_(msg`Feedback`)}>
|
label={_(msg`Feedback`)}>
|
||||||
{_(msg`Feedback`)}
|
{_(msg`Feedback`)}
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
{' • '}
|
<Text style={[t.atoms.text_contrast_low]}>{' ∙ '}</Text>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<InlineLinkText
|
<InlineLinkText
|
||||||
to="https://bsky.social/about/support/privacy-policy"
|
to="https://bsky.social/about/support/privacy-policy"
|
||||||
|
style={[t.atoms.text_contrast_medium]}
|
||||||
label={_(msg`Privacy`)}>
|
label={_(msg`Privacy`)}>
|
||||||
{_(msg`Privacy`)}
|
{_(msg`Privacy`)}
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
{' • '}
|
<Text style={[t.atoms.text_contrast_low]}>{' ∙ '}</Text>
|
||||||
<InlineLinkText
|
<InlineLinkText
|
||||||
to="https://bsky.social/about/support/tos"
|
to="https://bsky.social/about/support/tos"
|
||||||
|
style={[t.atoms.text_contrast_medium]}
|
||||||
label={_(msg`Terms`)}>
|
label={_(msg`Terms`)}>
|
||||||
{_(msg`Terms`)}
|
{_(msg`Terms`)}
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
{' • '}
|
<Text style={[t.atoms.text_contrast_low]}>{' ∙ '}</Text>
|
||||||
<InlineLinkText label={_(msg`Help`)} to={HELP_DESK_URL}>
|
<InlineLinkText
|
||||||
|
label={_(msg`Help`)}
|
||||||
|
to={HELP_DESK_URL}
|
||||||
|
style={[t.atoms.text_contrast_medium]}>
|
||||||
{_(msg`Help`)}
|
{_(msg`Help`)}
|
||||||
</InlineLinkText>
|
</InlineLinkText>
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ function Inner() {
|
|||||||
<TrendingTopicLink
|
<TrendingTopicLink
|
||||||
key={topic.link}
|
key={topic.link}
|
||||||
topic={topic}
|
topic={topic}
|
||||||
|
style={[a.self_start]}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
logEvent('trendingTopic:click', {context: 'sidebar'})
|
logEvent('trendingTopic:click', {context: 'sidebar'})
|
||||||
}}>
|
}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user