mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Add sentry support
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useMemo } from 'react'
|
||||
import React, { useCallback } from 'react'
|
||||
import { Pressable, StyleSheet, View } from 'react-native'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
|
||||
@ -44,18 +44,29 @@ const TimelineConversation: React.FC<Props> = ({
|
||||
|
||||
const navigation = useNavigation()
|
||||
|
||||
const conversationOnPress = useCallback(() => {
|
||||
const onPress = useCallback(() => {
|
||||
if (conversation.last_status) {
|
||||
conversation.unread && mutate({ id: conversation.id })
|
||||
navigation.navigate('Screen-Shared-Toot', {
|
||||
navigation.push('Screen-Shared-Toot', {
|
||||
toot: conversation.last_status
|
||||
})
|
||||
}
|
||||
}, [])
|
||||
|
||||
const conversationChildren = useMemo(() => {
|
||||
return (
|
||||
conversation.last_status && (
|
||||
return (
|
||||
<Pressable style={styles.conversationView} onPress={onPress}>
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar
|
||||
queryKey={queryKey}
|
||||
account={conversation.accounts[0]}
|
||||
/>
|
||||
<TimelineHeaderConversation
|
||||
queryKey={queryKey}
|
||||
conversation={conversation}
|
||||
/>
|
||||
</View>
|
||||
|
||||
{conversation.last_status ? (
|
||||
<View
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
@ -69,27 +80,7 @@ const TimelineConversation: React.FC<Props> = ({
|
||||
highlighted={highlighted}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
)
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<View style={styles.conversationView}>
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar
|
||||
queryKey={queryKey}
|
||||
account={conversation.accounts[0]}
|
||||
/>
|
||||
<TimelineHeaderConversation
|
||||
queryKey={queryKey}
|
||||
conversation={conversation}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Pressable
|
||||
onPress={conversationOnPress}
|
||||
children={conversationChildren}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<View
|
||||
style={{
|
||||
@ -102,10 +93,9 @@ const TimelineConversation: React.FC<Props> = ({
|
||||
queryKey={queryKey}
|
||||
status={conversation.last_status!}
|
||||
reblog={false}
|
||||
sameAccountRoot={false}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useMemo } from 'react'
|
||||
import React, { useCallback } from 'react'
|
||||
import { Dimensions, Pressable, StyleSheet, View } from 'react-native'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
|
||||
@ -44,7 +44,7 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
StyleConstants.Avatar.M - // Avatar width
|
||||
StyleConstants.Spacing.S // Avatar margin to the right
|
||||
|
||||
const tootOnPress = useCallback(
|
||||
const onPress = useCallback(
|
||||
() =>
|
||||
!isRemotePublic &&
|
||||
!highlighted &&
|
||||
@ -53,8 +53,26 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
}),
|
||||
[]
|
||||
)
|
||||
const tootChildren = useMemo(
|
||||
() => (
|
||||
return (
|
||||
<Pressable style={styles.statusView} onPress={onPress}>
|
||||
{item.reblog ? (
|
||||
<TimelineActioned action='reblog' account={item.account} />
|
||||
) : pinnedLength && index < pinnedLength ? (
|
||||
<TimelineActioned action='pinned' account={item.account} />
|
||||
) : null}
|
||||
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar
|
||||
{...(!isRemotePublic && { queryKey })}
|
||||
account={actualStatus.account}
|
||||
/>
|
||||
<TimelineHeaderDefault
|
||||
{...(!isRemotePublic && { queryKey })}
|
||||
status={actualStatus}
|
||||
sameAccount={actualStatus.account.id === localAccountId}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
@ -75,35 +93,13 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
/>
|
||||
)}
|
||||
{actualStatus.media_attachments.length > 0 && (
|
||||
<TimelineAttachment status={actualStatus} contentWidth={contentWidth} />
|
||||
<TimelineAttachment
|
||||
status={actualStatus}
|
||||
contentWidth={contentWidth}
|
||||
/>
|
||||
)}
|
||||
{actualStatus.card && <TimelineCard card={actualStatus.card} />}
|
||||
</View>
|
||||
),
|
||||
[actualStatus.poll]
|
||||
)
|
||||
|
||||
return (
|
||||
<View style={styles.statusView}>
|
||||
{item.reblog ? (
|
||||
<TimelineActioned action='reblog' account={item.account} />
|
||||
) : pinnedLength && index < pinnedLength ? (
|
||||
<TimelineActioned action='pinned' account={item.account} />
|
||||
) : null}
|
||||
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar
|
||||
{...(!isRemotePublic && { queryKey })}
|
||||
account={actualStatus.account}
|
||||
/>
|
||||
<TimelineHeaderDefault
|
||||
{...(!isRemotePublic && { queryKey })}
|
||||
status={actualStatus}
|
||||
sameAccount={actualStatus.account.id === localAccountId}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Pressable onPress={tootOnPress} children={tootChildren} />
|
||||
|
||||
{!isRemotePublic && (
|
||||
<View
|
||||
@ -117,11 +113,10 @@ const TimelineDefault: React.FC<Props> = ({
|
||||
queryKey={queryKey}
|
||||
status={actualStatus}
|
||||
reblog={item.reblog ? true : false}
|
||||
sameAccountRoot={item.account.id === localAccountId}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useCallback, useMemo } from 'react'
|
||||
import React, { useCallback } from 'react'
|
||||
import { Dimensions, Pressable, StyleSheet, View } from 'react-native'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
|
||||
@ -39,16 +39,28 @@ const TimelineNotifications: React.FC<Props> = ({
|
||||
StyleConstants.Avatar.M - // Avatar width
|
||||
StyleConstants.Spacing.S // Avatar margin to the right
|
||||
|
||||
const tootOnPress = useCallback(
|
||||
const onPress = useCallback(
|
||||
() =>
|
||||
navigation.navigate('Screen-Shared-Toot', {
|
||||
navigation.push('Screen-Shared-Toot', {
|
||||
toot: notification.status
|
||||
}),
|
||||
[]
|
||||
)
|
||||
const tootChildren = useMemo(
|
||||
() =>
|
||||
notification.status ? (
|
||||
|
||||
return (
|
||||
<Pressable style={styles.notificationView} onPress={onPress}>
|
||||
<TimelineActioned
|
||||
action={notification.type}
|
||||
account={notification.account}
|
||||
notification
|
||||
/>
|
||||
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar queryKey={queryKey} account={actualAccount} />
|
||||
<TimelineHeaderNotification notification={notification} />
|
||||
</View>
|
||||
|
||||
{notification.status ? (
|
||||
<View
|
||||
style={{
|
||||
paddingTop: highlighted ? StyleConstants.Spacing.S : 0,
|
||||
@ -81,24 +93,7 @@ const TimelineNotifications: React.FC<Props> = ({
|
||||
<TimelineCard card={notification.status.card} />
|
||||
)}
|
||||
</View>
|
||||
) : null,
|
||||
[notification.status?.poll?.voted]
|
||||
)
|
||||
|
||||
return (
|
||||
<View style={styles.notificationView}>
|
||||
<TimelineActioned
|
||||
action={notification.type}
|
||||
account={notification.account}
|
||||
notification
|
||||
/>
|
||||
|
||||
<View style={styles.header}>
|
||||
<TimelineAvatar queryKey={queryKey} account={actualAccount} />
|
||||
<TimelineHeaderNotification notification={notification} />
|
||||
</View>
|
||||
|
||||
<Pressable onPress={tootOnPress} children={tootChildren} />
|
||||
) : null}
|
||||
|
||||
{notification.status && (
|
||||
<View
|
||||
@ -112,11 +107,10 @@ const TimelineNotifications: React.FC<Props> = ({
|
||||
queryKey={queryKey}
|
||||
status={notification.status}
|
||||
reblog={false}
|
||||
sameAccountRoot={notification.account.id === localAccountId}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -49,15 +49,9 @@ export interface Props {
|
||||
queryKey: QueryKey.Timeline
|
||||
status: Mastodon.Status
|
||||
reblog: boolean
|
||||
sameAccountRoot: boolean
|
||||
}
|
||||
|
||||
const TimelineActions: React.FC<Props> = ({
|
||||
queryKey,
|
||||
status,
|
||||
reblog,
|
||||
sameAccountRoot
|
||||
}) => {
|
||||
const TimelineActions: React.FC<Props> = ({ queryKey, status, reblog }) => {
|
||||
const navigation = useNavigation()
|
||||
const { theme } = useTheme()
|
||||
const iconColor = theme.secondary
|
||||
@ -71,33 +65,18 @@ const TimelineActions: React.FC<Props> = ({
|
||||
const oldData = queryClient.getQueryData(queryKey)
|
||||
|
||||
switch (type) {
|
||||
// Update each specific page
|
||||
case 'favourite':
|
||||
case 'reblog':
|
||||
case 'bookmark':
|
||||
if (type === 'favourite' && queryKey[0] === 'Favourites') {
|
||||
queryClient.invalidateQueries(['Favourites', {}])
|
||||
break
|
||||
}
|
||||
if (
|
||||
type === 'reblog' &&
|
||||
queryKey[0] === 'Following' &&
|
||||
prevState === true &&
|
||||
sameAccountRoot
|
||||
) {
|
||||
queryClient.invalidateQueries(['Following'])
|
||||
break
|
||||
}
|
||||
if (type === 'bookmark' && queryKey[0] === 'Bookmarks') {
|
||||
queryClient.invalidateQueries(['Bookmarks', {}])
|
||||
break
|
||||
}
|
||||
|
||||
queryClient.setQueryData<TimelineData>(queryKey, old => {
|
||||
let tootIndex = -1
|
||||
const pageIndex = findIndex(old?.pages, page => {
|
||||
const tempIndex = findIndex(page.toots, [
|
||||
reblog ? 'reblog.id' : 'id',
|
||||
queryKey[0] === 'Notifications'
|
||||
? 'status.id'
|
||||
: reblog
|
||||
? 'reblog.id'
|
||||
: 'id',
|
||||
id
|
||||
])
|
||||
if (tempIndex >= 0) {
|
||||
@ -107,14 +86,29 @@ const TimelineActions: React.FC<Props> = ({
|
||||
return false
|
||||
}
|
||||
})
|
||||
console.log(queryKey)
|
||||
console.log('pageIndex', pageIndex)
|
||||
console.log('tootIndex', tootIndex)
|
||||
|
||||
if (pageIndex >= 0 && tootIndex >= 0) {
|
||||
if (reblog) {
|
||||
old!.pages[pageIndex].toots[tootIndex].reblog![stateKey] =
|
||||
typeof prevState === 'boolean' ? !prevState : true
|
||||
if (
|
||||
(type === 'favourite' && queryKey[0] === 'Favourites') ||
|
||||
(type === 'bookmark' && queryKey[0] === 'Bookmarks')
|
||||
) {
|
||||
old!.pages[pageIndex].toots.splice(tootIndex, 1)
|
||||
} else {
|
||||
old!.pages[pageIndex].toots[tootIndex][stateKey] =
|
||||
typeof prevState === 'boolean' ? !prevState : true
|
||||
if (queryKey[0] === 'Notifications') {
|
||||
old!.pages[pageIndex].toots[tootIndex].status[stateKey] =
|
||||
typeof prevState === 'boolean' ? !prevState : true
|
||||
} else {
|
||||
if (reblog) {
|
||||
old!.pages[pageIndex].toots[tootIndex].reblog![stateKey] =
|
||||
typeof prevState === 'boolean' ? !prevState : true
|
||||
} else {
|
||||
old!.pages[pageIndex].toots[tootIndex][stateKey] =
|
||||
typeof prevState === 'boolean' ? !prevState : true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user