Remove broadcast hack
This commit is contained in:
@@ -1,64 +0,0 @@
|
|||||||
import {View} from 'react-native'
|
|
||||||
import {ScrollView} from 'react-native-gesture-handler'
|
|
||||||
import {AppBskyGraphDefs} from '@atproto/api'
|
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
|
||||||
import {atoms as a, useBreakpoints, web} from '#/alf'
|
|
||||||
import {Embed} from './StarterPackCard'
|
|
||||||
|
|
||||||
const DESKTOP_CARD_WIDTH = 400
|
|
||||||
const MOBILE_CARD_WIDTH = 300
|
|
||||||
|
|
||||||
export function Grid({
|
|
||||||
isSuggestionsLoading,
|
|
||||||
error,
|
|
||||||
starterPacks,
|
|
||||||
}: {
|
|
||||||
isSuggestionsLoading: boolean
|
|
||||||
starterPacks: AppBskyGraphDefs.StarterPackViewBasic[]
|
|
||||||
error: Error | null
|
|
||||||
}) {
|
|
||||||
const moderationOpts = useModerationOpts()
|
|
||||||
const {gtMobile} = useBreakpoints()
|
|
||||||
const width = gtMobile ? DESKTOP_CARD_WIDTH : MOBILE_CARD_WIDTH
|
|
||||||
const isLoading = isSuggestionsLoading || !moderationOpts
|
|
||||||
const maxLength = gtMobile ? 4 : 6
|
|
||||||
|
|
||||||
const content = isLoading ? (
|
|
||||||
Array(maxLength)
|
|
||||||
.fill(0)
|
|
||||||
.map((_, i) => (
|
|
||||||
<View
|
|
||||||
key={i}
|
|
||||||
style={[gtMobile && web([a.flex_0, {width: 'calc(50% - 6px)'}])]}>
|
|
||||||
{/* TODO <SuggestedFollowPlaceholder /> */}
|
|
||||||
</View>
|
|
||||||
))
|
|
||||||
) : error || !starterPacks.length ? null : (
|
|
||||||
<>
|
|
||||||
{starterPacks.slice(0, maxLength).map(starterPack => (
|
|
||||||
<View key={starterPack.uri} style={[{width}]}>
|
|
||||||
<Embed starterPack={starterPack} />
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
|
|
||||||
if (error || (!isLoading && !starterPacks.length)) {
|
|
||||||
logger.debug(`Not enough starter packs to show suggested starter packs`)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ScrollView
|
|
||||||
horizontal
|
|
||||||
showsHorizontalScrollIndicator={false}
|
|
||||||
snapToInterval={width + a.gap_md.gap}
|
|
||||||
decelerationRate="fast">
|
|
||||||
<View style={[a.px_md, a.pt_sm, a.pb_lg, a.flex_row, a.gap_md]}>
|
|
||||||
{content}
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -63,10 +63,8 @@ export async function write<K extends keyof Schema>(
|
|||||||
[key]: value,
|
[key]: value,
|
||||||
})
|
})
|
||||||
writeToStorage(_state)
|
writeToStorage(_state)
|
||||||
setTimeout(() => {
|
broadcast.postMessage({event: {type: UPDATE_EVENT, key}})
|
||||||
broadcast.postMessage({event: {type: UPDATE_EVENT, key}})
|
broadcast.postMessage({event: UPDATE_EVENT}) // Backcompat while upgrading
|
||||||
broadcast.postMessage({event: UPDATE_EVENT}) // Backcompat while upgrading
|
|
||||||
}, 0)
|
|
||||||
}
|
}
|
||||||
write satisfies PersistedApi['write']
|
write satisfies PersistedApi['write']
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import {View} from 'react-native'
|
|||||||
import {
|
import {
|
||||||
AppBskyActorDefs,
|
AppBskyActorDefs,
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
AppBskyGraphDefs,
|
|
||||||
moderateProfile,
|
moderateProfile,
|
||||||
ModerationDecision,
|
ModerationDecision,
|
||||||
ModerationOpts,
|
ModerationOpts,
|
||||||
@@ -35,7 +34,6 @@ import {Props as SVGIconProps} from '#/components/icons/common'
|
|||||||
import {ListSparkle_Stroke2_Corner0_Rounded as ListSparkle} from '#/components/icons/ListSparkle'
|
import {ListSparkle_Stroke2_Corner0_Rounded as ListSparkle} from '#/components/icons/ListSparkle'
|
||||||
import {UserCircle_Stroke2_Corner0_Rounded as Person} from '#/components/icons/UserCircle'
|
import {UserCircle_Stroke2_Corner0_Rounded as Person} from '#/components/icons/UserCircle'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import * as StarterPackSuggestions from '#/components/StarterPack/Suggestions'
|
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
function SuggestedItemsHeader({
|
function SuggestedItemsHeader({
|
||||||
@@ -249,11 +247,6 @@ type ExploreScreenItems =
|
|||||||
type: 'trendingTopics'
|
type: 'trendingTopics'
|
||||||
key: string
|
key: string
|
||||||
}
|
}
|
||||||
| {
|
|
||||||
type: 'suggestedStarterPacks'
|
|
||||||
key: string
|
|
||||||
starterPacks: AppBskyGraphDefs.StarterPackViewBasic[]
|
|
||||||
}
|
|
||||||
| {
|
| {
|
||||||
type: 'profile'
|
type: 'profile'
|
||||||
key: string
|
key: string
|
||||||
@@ -513,15 +506,6 @@ export function Explore() {
|
|||||||
case 'trendingTopics': {
|
case 'trendingTopics': {
|
||||||
return <ExploreTrendingTopics />
|
return <ExploreTrendingTopics />
|
||||||
}
|
}
|
||||||
case 'suggestedStarterPacks': {
|
|
||||||
return (
|
|
||||||
<StarterPackSuggestions.Grid
|
|
||||||
isSuggestionsLoading={false}
|
|
||||||
error={null}
|
|
||||||
starterPacks={item.starterPacks}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
case 'profile': {
|
case 'profile': {
|
||||||
return (
|
return (
|
||||||
<View style={[a.border_b, t.atoms.border_contrast_low]}>
|
<View style={[a.border_b, t.atoms.border_contrast_low]}>
|
||||||
|
|||||||
Reference in New Issue
Block a user