1
0
mirror of https://github.com/tooot-app/app synced 2025-04-16 03:07:32 +02:00

Fix Sentry reports

This commit is contained in:
xmflsct 2022-12-04 17:56:47 +01:00
parent b70ca924a1
commit cb7762d18c
8 changed files with 24 additions and 50 deletions

View File

@ -126,7 +126,7 @@ const renderNode = ({
} }
}} }}
> >
{(content && content !== href && content) || (showFullLink ? href : domain[1])} {content && content !== href ? content : showFullLink ? href : domain?.[1]}
{!shouldBeTag ? ( {!shouldBeTag ? (
<Icon <Icon
color={colors.blue} color={colors.blue}

View File

@ -53,10 +53,10 @@ const TimelineDefault: React.FC<Props> = ({
const status = item.reblog ? item.reblog : item const status = item.reblog ? item.reblog : item
const ownAccount = status.account?.id === instanceAccount?.id const ownAccount = status.account?.id === instanceAccount?.id
const [spoilerExpanded, setSpoilerExpanded] = useState( const [spoilerExpanded, setSpoilerExpanded] = useState(
instanceAccount.preferences['reading:expand:spoilers'] || false instanceAccount?.preferences['reading:expand:spoilers'] || false
) )
const spoilerHidden = status.spoiler_text?.length const spoilerHidden = status.spoiler_text?.length
? !instanceAccount.preferences['reading:expand:spoilers'] && !spoilerExpanded ? !instanceAccount?.preferences['reading:expand:spoilers'] && !spoilerExpanded
: false : false
const copiableContent = useRef<{ content: string; complete: boolean }>({ const copiableContent = useRef<{ content: string; complete: boolean }>({
content: '', content: '',

View File

@ -20,23 +20,19 @@ const HeaderSharedAccount = React.memo(
<View style={{ flexDirection: 'row', alignItems: 'center' }}> <View style={{ flexDirection: 'row', alignItems: 'center' }}>
{withoutName ? null : ( {withoutName ? null : (
<CustomText <CustomText
accessibilityHint={t( accessibilityHint={t('shared.header.shared.account.name.accessibilityHint')}
'shared.header.shared.account.name.accessibilityHint'
)}
style={{ marginRight: StyleConstants.Spacing.XS }} style={{ marginRight: StyleConstants.Spacing.XS }}
numberOfLines={1} numberOfLines={1}
> >
<ParseEmojis <ParseEmojis
content={account?.display_name || account?.username} content={account?.display_name || account?.username}
emojis={account.emojis} emojis={account?.emojis}
fontBold fontBold
/> />
</CustomText> </CustomText>
)} )}
<CustomText <CustomText
accessibilityHint={t( accessibilityHint={t('shared.header.shared.account.account.accessibilityHint')}
'shared.header.shared.account.account.accessibilityHint'
)}
style={{ flexShrink: 1, color: colors.secondary }} style={{ flexShrink: 1, color: colors.secondary }}
numberOfLines={1} numberOfLines={1}
> >

View File

@ -26,10 +26,10 @@ export const uploadAttachment = async ({
}) => { }) => {
const hash = await Crypto.digestStringAsync( const hash = await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256, Crypto.CryptoDigestAlgorithm.SHA256,
media.uri + Math.random() media.uri + Math.random().toString()
) )
switch (media.type.split('/')[0]) { switch (media.type?.split('/')[0] || '') {
case 'image': case 'image':
composeDispatch({ composeDispatch({
type: 'attachment/upload/start', type: 'attachment/upload/start',
@ -77,15 +77,11 @@ export const uploadAttachment = async ({
payload: hash payload: hash
}) })
Alert.alert( Alert.alert(
i18next.t( i18next.t('screenCompose:content.root.actions.attachment.failed.alert.title'),
'screenCompose:content.root.actions.attachment.failed.alert.title'
),
message, message,
[ [
{ {
text: i18next.t( text: i18next.t('screenCompose:content.root.actions.attachment.failed.alert.button'),
'screenCompose:content.root.actions.attachment.failed.alert.button'
),
onPress: () => {} onPress: () => {}
} }
] ]
@ -117,9 +113,7 @@ export const uploadAttachment = async ({
}) })
.catch((err: any) => { .catch((err: any) => {
uploadFailed( uploadFailed(
err?.message && typeof err?.message === 'string' err?.message && typeof err?.message === 'string' ? err?.message.slice(0, 50) : undefined
? err?.message.slice(0, 50)
: undefined
) )
}) })
} }

View File

@ -37,25 +37,16 @@ const composePost = async (
formData.append('poll[multiple]', composeState.poll.multiple.toString()) formData.append('poll[multiple]', composeState.poll.multiple.toString())
} }
if ( if (composeState.attachments.uploads.filter(upload => upload.remote && upload.remote.id).length) {
composeState.attachments.uploads.filter(
upload => upload.remote && upload.remote.id
).length
) {
formData.append('sensitive', composeState.attachments.sensitive.toString()) formData.append('sensitive', composeState.attachments.sensitive.toString())
composeState.attachments.uploads.forEach(e => composeState.attachments.uploads.forEach(e => formData.append('media_ids[]', e.remote!.id!))
formData.append('media_ids[]', e.remote!.id!)
)
} }
formData.append('visibility', composeState.visibility) formData.append('visibility', composeState.visibility)
return apiInstance<Mastodon.Status>({ return apiInstance<Mastodon.Status>({
method: params?.type === 'edit' ? 'put' : 'post', method: params?.type === 'edit' ? 'put' : 'post',
url: url: params?.type === 'edit' ? `statuses/${params.incomingStatus.id}` : 'statuses',
params?.type === 'edit'
? `statuses/${params.incomingStatus.id}`
: 'statuses',
headers: { headers: {
'Idempotency-Key': await Crypto.digestStringAsync( 'Idempotency-Key': await Crypto.digestStringAsync(
Crypto.CryptoDigestAlgorithm.SHA256, Crypto.CryptoDigestAlgorithm.SHA256,
@ -70,9 +61,7 @@ const composePost = async (
composeState.attachments.sensitive + composeState.attachments.sensitive +
composeState.attachments.uploads.map(upload => upload.remote?.id) + composeState.attachments.uploads.map(upload => upload.remote?.id) +
composeState.visibility + composeState.visibility +
(params?.type === 'edit' || params?.type === 'deleteEdit' (params?.type === 'edit' || params?.type === 'deleteEdit' ? Math.random().toString() : '')
? Math.random()
: '')
) )
}, },
body: formData body: formData

View File

@ -3,10 +3,7 @@ import { useNavigation } from '@react-navigation/native'
import { useAppDispatch } from '@root/store' import { useAppDispatch } from '@root/store'
import { useAnnouncementQuery } from '@utils/queryHooks/announcement' import { useAnnouncementQuery } from '@utils/queryHooks/announcement'
import { useListsQuery } from '@utils/queryHooks/lists' import { useListsQuery } from '@utils/queryHooks/lists'
import { import { getInstanceMePage, updateInstanceMePage } from '@utils/slices/instancesSlice'
getInstanceMePage,
updateInstanceMePage
} from '@utils/slices/instancesSlice'
import { getInstancePush } from '@utils/slices/instancesSlice' import { getInstancePush } from '@utils/slices/instancesSlice'
import React, { useEffect } from 'react' import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
@ -41,19 +38,17 @@ const Collections: React.FC = () => {
} }
}) })
useEffect(() => { useEffect(() => {
if (announcementsQuery.isSuccess) { if (announcementsQuery.data) {
dispatch( dispatch(
updateInstanceMePage({ updateInstanceMePage({
announcements: { announcements: {
shown: announcementsQuery.data?.length ? true : false, shown: announcementsQuery.data.length ? true : false,
unread: announcementsQuery.data?.filter( unread: announcementsQuery.data.filter(announcement => !announcement.read).length
announcement => !announcement.read
).length
} }
}) })
) )
} }
}, [announcementsQuery.isSuccess, announcementsQuery.data?.length]) }, [announcementsQuery.data])
const instancePush = useSelector( const instancePush = useSelector(
getInstancePush, getInstancePush,
@ -100,9 +95,7 @@ const Collections: React.FC = () => {
}) })
: t('me.root.announcements.content.read') : t('me.root.announcements.content.read')
} }
onPress={() => onPress={() => navigation.navigate('Screen-Announcements', { showAll: true })}
navigation.navigate('Screen-Announcements', { showAll: true })
}
/> />
) : null} ) : null}
<MenuRow <MenuRow

View File

@ -51,6 +51,8 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
scrolled.current = true scrolled.current = true
const pointer = flattenData.findIndex(({ id }) => id === toot.id) const pointer = flattenData.findIndex(({ id }) => id === toot.id)
if (pointer < 1) return if (pointer < 1) return
const length = flRef.current?.props.data?.length
if (!length) return
try { try {
setTimeout(() => { setTimeout(() => {
try { try {

View File

@ -287,7 +287,7 @@ const instancesSlice = createSlice({
const activeIndex = findInstanceActive(state.instances) const activeIndex = findInstanceActive(state.instances)
state.instances[activeIndex].frequentEmojis = state.instances[ state.instances[activeIndex].frequentEmojis = state.instances[
activeIndex activeIndex
].frequentEmojis?.filter(emoji => { ]?.frequentEmojis?.filter(emoji => {
return action.payload?.find( return action.payload?.find(
e => e.shortcode === emoji.emoji.shortcode && e.url === emoji.emoji.url e => e.shortcode === emoji.emoji.shortcode && e.url === emoji.emoji.url
) )