mirror of https://github.com/tooot-app/app
Check for Wildebeest's account ID format
This commit is contained in:
parent
f98b8946dc
commit
fd114ed0f0
|
@ -12,11 +12,11 @@ import TimelinePoll from '@components/Timeline/Shared/Poll'
|
|||
import { useNavigation } from '@react-navigation/native'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { featureCheck } from '@utils/helpers/featureCheck'
|
||||
import { checkIsMyAccount } from '@utils/helpers/isMyAccount'
|
||||
import removeHTML from '@utils/helpers/removeHTML'
|
||||
import { TabLocalStackParamList } from '@utils/navigation/navigators'
|
||||
import { usePreferencesQuery } from '@utils/queryHooks/preferences'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { useAccountStorage } from '@utils/storage/actions'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React, { Fragment, useRef, useState } from 'react'
|
||||
|
@ -63,10 +63,9 @@ const TimelineDefault: React.FC<Props> = ({
|
|||
const { colors } = useTheme()
|
||||
const navigation = useNavigation<StackNavigationProp<TabLocalStackParamList>>()
|
||||
|
||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||
const { data: preferences } = usePreferencesQuery()
|
||||
|
||||
const ownAccount = status.account?.id === accountId
|
||||
const isMyAccount = checkIsMyAccount(status.account.id)
|
||||
const [spoilerExpanded, setSpoilerExpanded] = useState(
|
||||
preferences?.['reading:expand:spoilers'] || false
|
||||
)
|
||||
|
@ -136,7 +135,7 @@ const TimelineDefault: React.FC<Props> = ({
|
|||
const mStatus = menuStatus({ status, queryKey })
|
||||
const mInstance = menuInstance({ status, queryKey })
|
||||
|
||||
if (!ownAccount) {
|
||||
if (!isMyAccount) {
|
||||
let filterResults: FilteredProps['filterResults'] = []
|
||||
const [filterRevealed, setFilterRevealed] = useState(false)
|
||||
const hasFilterServerSide = featureCheck('filter_server_side')
|
||||
|
@ -166,7 +165,7 @@ const TimelineDefault: React.FC<Props> = ({
|
|||
value={{
|
||||
queryKey,
|
||||
status,
|
||||
ownAccount,
|
||||
isMyAccount,
|
||||
spoilerHidden,
|
||||
rawContent,
|
||||
detectedLanguage,
|
||||
|
|
|
@ -12,10 +12,10 @@ import TimelinePoll from '@components/Timeline/Shared/Poll'
|
|||
import { useNavigation } from '@react-navigation/native'
|
||||
import { StackNavigationProp } from '@react-navigation/stack'
|
||||
import { featureCheck } from '@utils/helpers/featureCheck'
|
||||
import { checkIsMyAccount } from '@utils/helpers/isMyAccount'
|
||||
import { TabLocalStackParamList } from '@utils/navigation/navigators'
|
||||
import { usePreferencesQuery } from '@utils/queryHooks/preferences'
|
||||
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
||||
import { useAccountStorage } from '@utils/storage/actions'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import { useTheme } from '@utils/styles/ThemeManager'
|
||||
import React, { Fragment, useState } from 'react'
|
||||
|
@ -32,7 +32,6 @@ export interface Props {
|
|||
}
|
||||
|
||||
const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||
const { data: preferences } = usePreferencesQuery()
|
||||
|
||||
const status = notification.status?.reblog ? notification.status.reblog : notification.status
|
||||
|
@ -42,7 +41,7 @@ const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
|||
: notification.status
|
||||
? notification.status.account
|
||||
: notification.account
|
||||
const ownAccount = notification.account?.id === accountId
|
||||
const isMyAccount = checkIsMyAccount(notification.account?.id)
|
||||
const [spoilerExpanded, setSpoilerExpanded] = useState(
|
||||
preferences?.['reading:expand:spoilers'] || false
|
||||
)
|
||||
|
@ -109,7 +108,7 @@ const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
|||
const mStatus = menuStatus({ status: notification.status, queryKey })
|
||||
const mInstance = menuInstance({ status: notification.status, queryKey })
|
||||
|
||||
if (!ownAccount) {
|
||||
if (!isMyAccount) {
|
||||
let filterResults: FilteredProps['filterResults'] = []
|
||||
const [filterRevealed, setFilterRevealed] = useState(false)
|
||||
const hasFilterServerSide = featureCheck('filter_server_side')
|
||||
|
@ -140,7 +139,7 @@ const TimelineNotifications: React.FC<Props> = ({ notification, queryKey }) => {
|
|||
value={{
|
||||
queryKey,
|
||||
status,
|
||||
ownAccount,
|
||||
isMyAccount,
|
||||
spoilerHidden
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -22,7 +22,7 @@ import { Pressable, StyleSheet, View } from 'react-native'
|
|||
import StatusContext from './Context'
|
||||
|
||||
const TimelineActions: React.FC = () => {
|
||||
const { queryKey, status, ownAccount, highlighted, disableDetails } = useContext(StatusContext)
|
||||
const { queryKey, status, isMyAccount, highlighted, disableDetails } = useContext(StatusContext)
|
||||
if (!queryKey || !status || disableDetails) return null
|
||||
|
||||
const navigationState = useNavState()
|
||||
|
@ -182,7 +182,7 @@ const TimelineActions: React.FC = () => {
|
|||
const childrenReblog = () => {
|
||||
const color = (state: boolean) => (state ? colors.green : colors.secondary)
|
||||
const disabled =
|
||||
status.visibility === 'direct' || (status.visibility === 'private' && !ownAccount)
|
||||
status.visibility === 'direct' || (status.visibility === 'private' && !isMyAccount)
|
||||
return (
|
||||
<>
|
||||
<Icon
|
||||
|
@ -196,7 +196,7 @@ const TimelineActions: React.FC = () => {
|
|||
fontStyle='S'
|
||||
style={{
|
||||
color:
|
||||
status.visibility === 'private' && !ownAccount
|
||||
status.visibility === 'private' && !isMyAccount
|
||||
? colors.disabled
|
||||
: color(status.reblogged),
|
||||
marginLeft: StyleConstants.Spacing.XS
|
||||
|
@ -258,7 +258,7 @@ const TimelineActions: React.FC = () => {
|
|||
onPress={onPressReblog}
|
||||
children={childrenReblog()}
|
||||
disabled={
|
||||
status.visibility === 'direct' || (status.visibility === 'private' && !ownAccount)
|
||||
status.visibility === 'direct' || (status.visibility === 'private' && !isMyAccount)
|
||||
}
|
||||
/>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ type StatusContextType = {
|
|||
|
||||
status?: Mastodon.Status
|
||||
|
||||
ownAccount?: boolean
|
||||
isMyAccount?: boolean
|
||||
spoilerHidden?: boolean
|
||||
rawContent?: React.MutableRefObject<string[]> // When highlighted, for translate, edit history
|
||||
detectedLanguage?: React.MutableRefObject<string>
|
||||
|
|
|
@ -21,7 +21,7 @@ import { Pressable, View } from 'react-native'
|
|||
import StatusContext from './Context'
|
||||
|
||||
const TimelinePoll: React.FC = () => {
|
||||
const { queryKey, status, ownAccount, spoilerHidden, disableDetails, highlighted } =
|
||||
const { queryKey, status, isMyAccount, spoilerHidden, disableDetails, highlighted } =
|
||||
useContext(StatusContext)
|
||||
if (!queryKey || !status || !status.poll) return null
|
||||
const poll = status.poll
|
||||
|
@ -72,7 +72,7 @@ const TimelinePoll: React.FC = () => {
|
|||
|
||||
const pollButton = () => {
|
||||
if (!poll.expired) {
|
||||
if (!ownAccount && !poll.voted) {
|
||||
if (!isMyAccount && !poll.voted) {
|
||||
return (
|
||||
<View style={{ marginRight: StyleConstants.Spacing.S }}>
|
||||
<Button
|
||||
|
|
|
@ -4,6 +4,7 @@ import { useNavigation } from '@react-navigation/native'
|
|||
import { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import apiInstance from '@utils/api/instance'
|
||||
import { checkIsMyAccount } from '@utils/helpers/isMyAccount'
|
||||
import { TabSharedStackParamList, useNavState } from '@utils/navigation/navigators'
|
||||
import { useAccountQuery } from '@utils/queryHooks/account'
|
||||
import {
|
||||
|
@ -15,7 +16,7 @@ import {
|
|||
MutationVarsTimelineUpdateAccountProperty,
|
||||
useTimelineMutation
|
||||
} from '@utils/queryHooks/timeline'
|
||||
import { getAccountStorage, getReadableAccounts, useAccountStorage } from '@utils/storage/actions'
|
||||
import { getAccountStorage, getReadableAccounts } from '@utils/storage/actions'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Alert, Platform } from 'react-native'
|
||||
|
@ -40,19 +41,18 @@ const menuAccount = ({
|
|||
|
||||
const [enabled, setEnabled] = useState(openChange)
|
||||
useEffect(() => {
|
||||
if (!ownAccount && enabled === false && openChange === true) {
|
||||
if (!isMyAccount && enabled === false && openChange === true) {
|
||||
setEnabled(true)
|
||||
}
|
||||
}, [openChange, enabled])
|
||||
const { data: fetchedAccount } = useAccountQuery({ account, _local: true, options: { enabled } })
|
||||
const actualAccount = status?._remote ? fetchedAccount : account
|
||||
const isMyAccount = checkIsMyAccount(actualAccount?.id)
|
||||
const { data, isFetched } = useRelationshipQuery({
|
||||
id: actualAccount?.id,
|
||||
options: { enabled: !!actualAccount?.id && enabled }
|
||||
})
|
||||
|
||||
const ownAccount = useAccountStorage.string('auth.account.id')['0'] === actualAccount?.id
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
const timelineMutation = useTimelineMutation({
|
||||
onSuccess: (_, params) => {
|
||||
|
@ -134,7 +134,7 @@ const menuAccount = ({
|
|||
|
||||
if (!account) return []
|
||||
|
||||
if (!ownAccount && Platform.OS !== 'android' && type !== 'account') {
|
||||
if (!isMyAccount && Platform.OS !== 'android' && type !== 'account') {
|
||||
menus[0].push({
|
||||
type: 'item',
|
||||
key: 'account-following',
|
||||
|
@ -165,7 +165,7 @@ const menuAccount = ({
|
|||
})
|
||||
}
|
||||
|
||||
if (!ownAccount) {
|
||||
if (!isMyAccount) {
|
||||
menus[0].push({
|
||||
type: 'item',
|
||||
key: 'account-list',
|
||||
|
|
|
@ -4,6 +4,7 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
|||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import apiInstance from '@utils/api/instance'
|
||||
import { featureCheck } from '@utils/helpers/featureCheck'
|
||||
import { checkIsMyAccount } from '@utils/helpers/isMyAccount'
|
||||
import { RootStackParamList, useNavState } from '@utils/navigation/navigators'
|
||||
import {
|
||||
MutationVarsTimelineUpdateStatusProperty,
|
||||
|
@ -57,9 +58,8 @@ const menuStatus = ({
|
|||
|
||||
const menus: ContextMenu = []
|
||||
|
||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||
const [accountAcct] = useAccountStorage.string('auth.account.acct')
|
||||
const ownAccount = accountId === status.account?.id
|
||||
const isMyAccount = checkIsMyAccount(status.account.id)
|
||||
|
||||
const canEditPost = featureCheck('edit_post')
|
||||
|
||||
|
@ -98,7 +98,7 @@ const menuStatus = ({
|
|||
},
|
||||
disabled: false,
|
||||
destructive: false,
|
||||
hidden: !ownAccount || !canEditPost
|
||||
hidden: !isMyAccount || !canEditPost
|
||||
},
|
||||
title: t('componentContextMenu:status.edit.action'),
|
||||
icon: 'square.and.pencil'
|
||||
|
@ -142,7 +142,7 @@ const menuStatus = ({
|
|||
),
|
||||
disabled: false,
|
||||
destructive: true,
|
||||
hidden: !ownAccount
|
||||
hidden: !isMyAccount
|
||||
},
|
||||
title: t('componentContextMenu:status.deleteEdit.action'),
|
||||
icon: 'pencil.and.outline'
|
||||
|
@ -171,7 +171,7 @@ const menuStatus = ({
|
|||
),
|
||||
disabled: false,
|
||||
destructive: true,
|
||||
hidden: !ownAccount
|
||||
hidden: !isMyAccount
|
||||
},
|
||||
title: t('componentContextMenu:status.delete.action'),
|
||||
icon: 'trash'
|
||||
|
@ -195,7 +195,7 @@ const menuStatus = ({
|
|||
disabled: false,
|
||||
destructive: false,
|
||||
hidden:
|
||||
!ownAccount &&
|
||||
!isMyAccount &&
|
||||
queryKey[1].page !== 'Notifications' &&
|
||||
!status.mentions?.find(
|
||||
mention => mention.acct === accountAcct && mention.username === accountAcct
|
||||
|
@ -224,7 +224,7 @@ const menuStatus = ({
|
|||
}),
|
||||
disabled: status.visibility !== 'public' && status.visibility !== 'unlisted',
|
||||
destructive: false,
|
||||
hidden: !ownAccount
|
||||
hidden: !isMyAccount
|
||||
},
|
||||
title: t('componentContextMenu:status.pin.action', {
|
||||
defaultValue: 'false',
|
||||
|
@ -236,8 +236,9 @@ const menuStatus = ({
|
|||
type: 'item',
|
||||
key: 'status-filter',
|
||||
props: {
|
||||
// @ts-ignore
|
||||
onSelect: () => navigation.navigate('Tab-Shared-Filter', { source: 'status', status, queryKey }),
|
||||
onSelect: () =>
|
||||
// @ts-ignore
|
||||
navigation.navigate('Tab-Shared-Filter', { source: 'status', status, queryKey }),
|
||||
disabled: false,
|
||||
destructive: false,
|
||||
hidden: !('filtered' in status)
|
||||
|
|
|
@ -2,7 +2,7 @@ import Button from '@components/Button'
|
|||
import menuAt from '@components/contextMenu/at'
|
||||
import { RelationshipOutgoing } from '@components/Relationship'
|
||||
import { useNavigation } from '@react-navigation/native'
|
||||
import { useAccountStorage } from '@utils/storage/actions'
|
||||
import { checkIsMyAccount } from '@utils/helpers/isMyAccount'
|
||||
import { StyleConstants } from '@utils/styles/constants'
|
||||
import React, { useContext } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
@ -56,12 +56,11 @@ const AccountInformationActions: React.FC = () => {
|
|||
)
|
||||
}
|
||||
|
||||
const [accountId] = useAccountStorage.string('auth.account.id')
|
||||
const ownAccount = account?.id === accountId
|
||||
const isMyAccount = checkIsMyAccount(account?.id)
|
||||
|
||||
const mAt = menuAt({ account })
|
||||
|
||||
if (!ownAccount && account) {
|
||||
if (!isMyAccount && account) {
|
||||
return (
|
||||
<View style={styles.base}>
|
||||
{relationship && !relationship.blocked_by ? (
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import { getAccountStorage } from '@utils/storage/actions'
|
||||
|
||||
export const checkIsMyAccount = (id?: Mastodon.Account['id']): boolean => {
|
||||
if (!id) return false
|
||||
|
||||
const accountId = getAccountStorage.string('auth.account.id')
|
||||
const accountDomain = getAccountStorage.string('auth.account.domain')
|
||||
return accountId === id || `${accountId}@${accountDomain}` === id
|
||||
}
|
Loading…
Reference in New Issue