mirror of https://github.com/tooot-app/app
Fix pinned statuses on account page
This commit is contained in:
parent
4afdaf84c1
commit
fa3c298b8a
|
@ -19,14 +19,13 @@ import { Pressable, StyleSheet, View } from 'react-native'
|
|||
import { useSelector } from 'react-redux'
|
||||
|
||||
export interface Props {
|
||||
item: Mastodon.Status & { isPinned?: boolean }
|
||||
item: Mastodon.Status & { _pinned?: boolean } // For account page, internal property
|
||||
queryKey?: QueryKeyTimeline
|
||||
rootQueryKey?: QueryKeyTimeline
|
||||
origin?: string
|
||||
highlighted?: boolean
|
||||
disableDetails?: boolean
|
||||
disableOnPress?: boolean
|
||||
pinned?: Mastodon.Status['id'][]
|
||||
}
|
||||
|
||||
// When the poll is long
|
||||
|
@ -37,8 +36,7 @@ const TimelineDefault: React.FC<Props> = ({
|
|||
origin,
|
||||
highlighted = false,
|
||||
disableDetails = false,
|
||||
disableOnPress = false,
|
||||
pinned
|
||||
disableOnPress = false
|
||||
}) => {
|
||||
const { theme } = useTheme()
|
||||
const instanceAccount = useSelector(getInstanceAccount, () => true)
|
||||
|
@ -76,7 +74,7 @@ const TimelineDefault: React.FC<Props> = ({
|
|||
>
|
||||
{item.reblog ? (
|
||||
<TimelineActioned action='reblog' account={item.account} />
|
||||
) : pinned && pinned.includes(item.id) ? (
|
||||
) : item._pinned ? (
|
||||
<TimelineActioned action='pinned' account={item.account} />
|
||||
) : null}
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ const TabSharedAccount: React.FC<SharedAccountProp> = ({
|
|||
customProps={{
|
||||
renderItem,
|
||||
onScroll,
|
||||
scrollEventThrottle: 16,
|
||||
ListHeaderComponent
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -76,15 +76,17 @@ const queryFunction = ({
|
|||
}
|
||||
})
|
||||
} else {
|
||||
return apiInstance<(Mastodon.Status & { isPinned: boolean })[]>({
|
||||
return apiInstance<(Mastodon.Status & { _pinned: boolean })[]>({
|
||||
method: 'get',
|
||||
url: `accounts/${account}/statuses`,
|
||||
params: {
|
||||
pinned: 'true'
|
||||
}
|
||||
}).then(async res1 => {
|
||||
let pinned: Mastodon.Status['id'][] = []
|
||||
res1.body.forEach(status => pinned.push(status.id))
|
||||
res1.body = res1.body.map(status => {
|
||||
status._pinned = true
|
||||
return status
|
||||
})
|
||||
const res2 = await apiInstance<Mastodon.Status[]>({
|
||||
method: 'get',
|
||||
url: `accounts/${account}/statuses`,
|
||||
|
@ -94,8 +96,7 @@ const queryFunction = ({
|
|||
})
|
||||
return {
|
||||
body: uniqBy([...res1.body, ...res2.body], 'id'),
|
||||
...(res2.links.next && { links: { next: res2.links.next } }),
|
||||
pinned
|
||||
...(res2.links.next && { links: { next: res2.links.next } })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue