Let's go a different route
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
|||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
AppBskyGraphDefs,
|
AppBskyGraphDefs,
|
||||||
AtUri,
|
AtUri,
|
||||||
ModerationDecision,
|
|
||||||
RichText as RichTextApi,
|
RichText as RichTextApi,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {msg, plural, Trans} from '@lingui/macro'
|
import {msg, plural, Trans} from '@lingui/macro'
|
||||||
@@ -36,7 +35,6 @@ import {Text} from '#/components/Typography'
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
view: AppBskyFeedDefs.GeneratorView
|
view: AppBskyFeedDefs.GeneratorView
|
||||||
moderation?: ModerationDecision
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Default(props: Props) {
|
export function Default(props: Props) {
|
||||||
|
|||||||
+16
-47
@@ -1,10 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {ActivityIndicator, type FlatList, StyleSheet, View} from 'react-native'
|
import {ActivityIndicator, type FlatList, StyleSheet, View} from 'react-native'
|
||||||
import {
|
import {AppBskyFeedDefs} from '@atproto/api'
|
||||||
AppBskyFeedDefs,
|
|
||||||
moderateFeedGenerator,
|
|
||||||
ModerationDecision,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {msg, Trans} from '@lingui/macro'
|
import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
import {useFocusEffect} from '@react-navigation/native'
|
import {useFocusEffect} from '@react-navigation/native'
|
||||||
@@ -42,7 +38,6 @@ import {FilterTimeline_Stroke2_Corner0_Rounded as FilterTimeline} from '#/compon
|
|||||||
import {ListMagnifyingGlass_Stroke2_Corner0_Rounded} from '#/components/icons/ListMagnifyingGlass'
|
import {ListMagnifyingGlass_Stroke2_Corner0_Rounded} from '#/components/icons/ListMagnifyingGlass'
|
||||||
import {ListSparkle_Stroke2_Corner0_Rounded} from '#/components/icons/ListSparkle'
|
import {ListSparkle_Stroke2_Corner0_Rounded} from '#/components/icons/ListSparkle'
|
||||||
import hairlineWidth = StyleSheet.hairlineWidth
|
import hairlineWidth = StyleSheet.hairlineWidth
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
|
||||||
import {Divider} from '#/components/Divider'
|
import {Divider} from '#/components/Divider'
|
||||||
import * as FeedCard from '#/components/FeedCard'
|
import * as FeedCard from '#/components/FeedCard'
|
||||||
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron'
|
import {ChevronRight_Stroke2_Corner0_Rounded as ChevronRight} from '#/components/icons/Chevron'
|
||||||
@@ -94,7 +89,6 @@ type FlatlistSlice =
|
|||||||
key: string
|
key: string
|
||||||
feedUri: string
|
feedUri: string
|
||||||
feed: AppBskyFeedDefs.GeneratorView
|
feed: AppBskyFeedDefs.GeneratorView
|
||||||
moderation: ModerationDecision
|
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'popularFeedsLoadingMore'
|
type: 'popularFeedsLoadingMore'
|
||||||
@@ -107,7 +101,6 @@ type FlatlistSlice =
|
|||||||
|
|
||||||
export function FeedsScreen(_props: Props) {
|
export function FeedsScreen(_props: Props) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const moderationOpts = useModerationOpts()
|
|
||||||
const {openComposer} = useComposerControls()
|
const {openComposer} = useComposerControls()
|
||||||
const {isMobile, isTabletOrDesktop} = useWebMediaQueries()
|
const {isMobile, isTabletOrDesktop} = useWebMediaQueries()
|
||||||
const [query, setQuery] = React.useState('')
|
const [query, setQuery] = React.useState('')
|
||||||
@@ -307,7 +300,7 @@ export function FeedsScreen(_props: Props) {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (isUserSearching) {
|
if (isUserSearching) {
|
||||||
if (isSearchPending || !searchResults || !moderationOpts) {
|
if (isSearchPending || !searchResults) {
|
||||||
slices.push({
|
slices.push({
|
||||||
key: 'popularFeedsLoading',
|
key: 'popularFeedsLoading',
|
||||||
type: 'popularFeedsLoading',
|
type: 'popularFeedsLoading',
|
||||||
@@ -320,30 +313,17 @@ export function FeedsScreen(_props: Props) {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
slices = slices.concat(
|
slices = slices.concat(
|
||||||
searchResults
|
searchResults.map(feed => ({
|
||||||
.map(feed => {
|
key: `popularFeed:${feed.uri}`,
|
||||||
const moderation = moderateFeedGenerator(
|
type: 'popularFeed',
|
||||||
feed,
|
feedUri: feed.uri,
|
||||||
moderationOpts,
|
feed,
|
||||||
)
|
})),
|
||||||
const slice: FlatlistSlice = {
|
|
||||||
key: `popularFeed:${feed.uri}`,
|
|
||||||
type: 'popularFeed',
|
|
||||||
feedUri: feed.uri,
|
|
||||||
feed,
|
|
||||||
moderation,
|
|
||||||
}
|
|
||||||
return slice
|
|
||||||
})
|
|
||||||
.filter(i => !i.moderation.ui('contentList').filter),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (isPopularFeedsFetching && !popularFeeds?.pages) {
|
||||||
(isPopularFeedsFetching && !popularFeeds?.pages) ||
|
|
||||||
!moderationOpts
|
|
||||||
) {
|
|
||||||
slices.push({
|
slices.push({
|
||||||
key: 'popularFeedsLoading',
|
key: 'popularFeedsLoading',
|
||||||
type: 'popularFeedsLoading',
|
type: 'popularFeedsLoading',
|
||||||
@@ -357,22 +337,12 @@ export function FeedsScreen(_props: Props) {
|
|||||||
} else {
|
} else {
|
||||||
for (const page of popularFeeds.pages || []) {
|
for (const page of popularFeeds.pages || []) {
|
||||||
slices = slices.concat(
|
slices = slices.concat(
|
||||||
page.feeds
|
page.feeds.map(feed => ({
|
||||||
.map(feed => {
|
key: `popularFeed:${feed.uri}`,
|
||||||
const moderation = moderateFeedGenerator(
|
type: 'popularFeed',
|
||||||
feed,
|
feedUri: feed.uri,
|
||||||
moderationOpts,
|
feed,
|
||||||
)
|
})),
|
||||||
const slice: FlatlistSlice = {
|
|
||||||
key: `popularFeed:${feed.uri}`,
|
|
||||||
type: 'popularFeed',
|
|
||||||
feedUri: feed.uri,
|
|
||||||
feed,
|
|
||||||
moderation,
|
|
||||||
}
|
|
||||||
return slice
|
|
||||||
})
|
|
||||||
.filter(i => !i.moderation.ui('contentList').filter),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +372,6 @@ export function FeedsScreen(_props: Props) {
|
|||||||
isSearchPending,
|
isSearchPending,
|
||||||
searchError,
|
searchError,
|
||||||
isUserSearching,
|
isUserSearching,
|
||||||
moderationOpts,
|
|
||||||
])
|
])
|
||||||
|
|
||||||
const renderHeaderBtn = React.useCallback(() => {
|
const renderHeaderBtn = React.useCallback(() => {
|
||||||
@@ -527,7 +496,7 @@ export function FeedsScreen(_props: Props) {
|
|||||||
} else if (item.type === 'popularFeed') {
|
} else if (item.type === 'popularFeed') {
|
||||||
return (
|
return (
|
||||||
<View style={[a.px_lg, a.pt_lg, a.gap_lg]}>
|
<View style={[a.px_lg, a.pt_lg, a.gap_lg]}>
|
||||||
<FeedCard.Default view={item.feed} moderation={item.moderation} />
|
<FeedCard.Default view={item.feed} />
|
||||||
<Divider />
|
<Divider />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user