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,
|
||||
})
|
||||
writeToStorage(_state)
|
||||
setTimeout(() => {
|
||||
broadcast.postMessage({event: {type: UPDATE_EVENT, key}})
|
||||
broadcast.postMessage({event: UPDATE_EVENT}) // Backcompat while upgrading
|
||||
}, 0)
|
||||
broadcast.postMessage({event: {type: UPDATE_EVENT, key}})
|
||||
broadcast.postMessage({event: UPDATE_EVENT}) // Backcompat while upgrading
|
||||
}
|
||||
write satisfies PersistedApi['write']
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import {View} from 'react-native'
|
||||
import {
|
||||
AppBskyActorDefs,
|
||||
AppBskyFeedDefs,
|
||||
AppBskyGraphDefs,
|
||||
moderateProfile,
|
||||
ModerationDecision,
|
||||
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 {UserCircle_Stroke2_Corner0_Rounded as Person} from '#/components/icons/UserCircle'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import * as StarterPackSuggestions from '#/components/StarterPack/Suggestions'
|
||||
import {Text} from '#/components/Typography'
|
||||
|
||||
function SuggestedItemsHeader({
|
||||
@@ -249,11 +247,6 @@ type ExploreScreenItems =
|
||||
type: 'trendingTopics'
|
||||
key: string
|
||||
}
|
||||
| {
|
||||
type: 'suggestedStarterPacks'
|
||||
key: string
|
||||
starterPacks: AppBskyGraphDefs.StarterPackViewBasic[]
|
||||
}
|
||||
| {
|
||||
type: 'profile'
|
||||
key: string
|
||||
@@ -513,15 +506,6 @@ export function Explore() {
|
||||
case 'trendingTopics': {
|
||||
return <ExploreTrendingTopics />
|
||||
}
|
||||
case 'suggestedStarterPacks': {
|
||||
return (
|
||||
<StarterPackSuggestions.Grid
|
||||
isSuggestionsLoading={false}
|
||||
error={null}
|
||||
starterPacks={item.starterPacks}
|
||||
/>
|
||||
)
|
||||
}
|
||||
case 'profile': {
|
||||
return (
|
||||
<View style={[a.border_b, t.atoms.border_contrast_low]}>
|
||||
|
||||
Reference in New Issue
Block a user