Skip to content

Commit

Permalink
add in moderation to landing screen
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Jun 18, 2024
1 parent 6ecb0d2 commit e7f0c25
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/screens/StarterPack/StarterPackLandingScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from 'react'
import {Pressable, ScrollView, View} from 'react-native'
import Animated, {FadeIn, FadeOut} from 'react-native-reanimated'
import {AppBskyGraphDefs, AppBskyGraphStarterpack, AtUri} from '@atproto/api'
import {
AppBskyGraphDefs,
AppBskyGraphStarterpack,
AtUri,
ModerationOpts,
} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'

Expand All @@ -12,6 +17,7 @@ import {
parseStarterPackHttpUri,
} from 'lib/strings/starter-pack'
import {isWeb} from 'platform/detection'
import {useModerationOpts} from 'state/preferences/moderation-opts'
import {
useCurrentStarterPack,
useSetCurrentStarterPack,
Expand All @@ -28,7 +34,7 @@ import {Divider} from '#/components/Divider'
import * as FeedCard from '#/components/FeedCard'
import {LinearGradientBackground} from '#/components/LinearGradientBackground'
import {ListMaybePlaceholder} from '#/components/Lists'
import {Default as ProfileCardInner} from '#/components/ProfileCard'
import {Default as ProfileCard} from '#/components/ProfileCard'
import * as Prompt from '#/components/Prompt'
import {Text} from '#/components/Typography'

Expand Down Expand Up @@ -63,14 +69,20 @@ export function LandingScreen({
return null
}

return <LandingScreenInner setScreenState={setScreenState} />
return (
<LandingScreenInner
setScreenState={setScreenState}
moderationOpts={moderationOpts}
/>
)
}

export function LandingScreenInner({
setScreenState,
}: {
setScreenState: (state: LoggedOutScreenState) => void
}) {
const moderationOpts = useModerationOpts()
const currentStarterPack = useCurrentStarterPack()
const {name, rkey} =
parseStarterPackHttpUri(currentStarterPack?.uri || '') ?? {}
Expand All @@ -97,10 +109,12 @@ export function LandingScreenInner({
}
}, [isErrorDid, isErrorStarterPack, setScreenState, isValid, starterPack])

if (!did || !starterPack || !isValid) {
if (!did || !starterPack || !isValid || !moderationOpts) {
return (
<ListMaybePlaceholder
isLoading={isLoadingDid || isLoadingStarterPack || !isValid}
isLoading={
isLoadingDid || isLoadingStarterPack || !isValid || !moderationOpts
}
/>
)
}
Expand All @@ -116,9 +130,13 @@ export function LandingScreenInner({
function LandingScreenLoaded({
starterPack,
setScreenState,
// TODO apply this to profile card
// eslint-disable-next-line @typescript-eslint/no-unused-vars
moderationOpts,
}: {
starterPack: AppBskyGraphDefs.StarterPackView
setScreenState: (state: LoggedOutScreenState) => void
moderationOpts: ModerationOpts
}) {
const {record, creator, listItemsSample, feeds, joinedWeekCount} = starterPack
const {_} = useLingui()
Expand Down Expand Up @@ -289,7 +307,7 @@ function LandingScreenLoaded({
index !== 0 && a.border_t,
t.atoms.border_contrast_low,
]}>
<ProfileCardInner profile={item.subject} />
<ProfileCard profile={item.subject} />
</View>
))}
</View>
Expand Down

0 comments on commit e7f0c25

Please sign in to comment.