1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Fix pinned statuses on account page

This commit is contained in:
Zhiyuan Zheng
2021-03-09 10:35:53 +01:00
parent 4afdaf84c1
commit fa3c298b8a
3 changed files with 9 additions and 11 deletions

View File

@ -19,14 +19,13 @@ import { Pressable, StyleSheet, View } from 'react-native'
import { useSelector } from 'react-redux' import { useSelector } from 'react-redux'
export interface Props { export interface Props {
item: Mastodon.Status & { isPinned?: boolean } item: Mastodon.Status & { _pinned?: boolean } // For account page, internal property
queryKey?: QueryKeyTimeline queryKey?: QueryKeyTimeline
rootQueryKey?: QueryKeyTimeline rootQueryKey?: QueryKeyTimeline
origin?: string origin?: string
highlighted?: boolean highlighted?: boolean
disableDetails?: boolean disableDetails?: boolean
disableOnPress?: boolean disableOnPress?: boolean
pinned?: Mastodon.Status['id'][]
} }
// When the poll is long // When the poll is long
@ -37,8 +36,7 @@ const TimelineDefault: React.FC<Props> = ({
origin, origin,
highlighted = false, highlighted = false,
disableDetails = false, disableDetails = false,
disableOnPress = false, disableOnPress = false
pinned
}) => { }) => {
const { theme } = useTheme() const { theme } = useTheme()
const instanceAccount = useSelector(getInstanceAccount, () => true) const instanceAccount = useSelector(getInstanceAccount, () => true)
@ -76,7 +74,7 @@ const TimelineDefault: React.FC<Props> = ({
> >
{item.reblog ? ( {item.reblog ? (
<TimelineActioned action='reblog' account={item.account} /> <TimelineActioned action='reblog' account={item.account} />
) : pinned && pinned.includes(item.id) ? ( ) : item._pinned ? (
<TimelineActioned action='pinned' account={item.account} /> <TimelineActioned action='pinned' account={item.account} />
) : null} ) : null}

View File

@ -88,7 +88,6 @@ const TabSharedAccount: React.FC<SharedAccountProp> = ({
customProps={{ customProps={{
renderItem, renderItem,
onScroll, onScroll,
scrollEventThrottle: 16,
ListHeaderComponent ListHeaderComponent
}} }}
/> />

View File

@ -76,15 +76,17 @@ const queryFunction = ({
} }
}) })
} else { } else {
return apiInstance<(Mastodon.Status & { isPinned: boolean })[]>({ return apiInstance<(Mastodon.Status & { _pinned: boolean })[]>({
method: 'get', method: 'get',
url: `accounts/${account}/statuses`, url: `accounts/${account}/statuses`,
params: { params: {
pinned: 'true' pinned: 'true'
} }
}).then(async res1 => { }).then(async res1 => {
let pinned: Mastodon.Status['id'][] = [] res1.body = res1.body.map(status => {
res1.body.forEach(status => pinned.push(status.id)) status._pinned = true
return status
})
const res2 = await apiInstance<Mastodon.Status[]>({ const res2 = await apiInstance<Mastodon.Status[]>({
method: 'get', method: 'get',
url: `accounts/${account}/statuses`, url: `accounts/${account}/statuses`,
@ -94,8 +96,7 @@ const queryFunction = ({
}) })
return { return {
body: uniqBy([...res1.body, ...res2.body], 'id'), body: uniqBy([...res1.body, ...res2.body], 'id'),
...(res2.links.next && { links: { next: res2.links.next } }), ...(res2.links.next && { links: { next: res2.links.next } })
pinned
} }
}) })
} }