diff --git a/src/@types/mastodon.d.ts b/src/@types/mastodon.d.ts index 8b58589b..7fec5552 100644 --- a/src/@types/mastodon.d.ts +++ b/src/@types/mastodon.d.ts @@ -333,24 +333,34 @@ declare namespace Mastodon { url: string } - type Notification = { - // Base - id: string - type: - | 'follow' - | 'follow_request' - | 'mention' - | 'reblog' - | 'favourite' - | 'poll' - | 'status' - | 'update' - created_at: string - account: Account - - // Others - status?: Status - } + type Notification = + | { + // Base + id: string + type: 'favourite' | 'mention' | 'poll' | 'reblog' | 'status' | 'update' + created_at: string + account: Account + status: Status + report: undefined + } + | { + // Base + id: string + type: 'follow' | 'follow_request' | 'admin.sign_up' + created_at: string + account: Account + status: undefined + report: undefined + } + | { + // Base + id: string + type: 'admin.report' + created_at: string + account: Account + status: undefined + report: Report + } type Poll = { // Base @@ -406,6 +416,19 @@ declare namespace Mastodon { note: string } + type Report = { + id: string + action_taken: boolean + action_taken_at?: string + category: 'spam' | 'violation' | 'other' + comment: string + forwarded: boolean + created_at: string + status_ids?: string[] + rule_ids?: string[] + target_account: Account + } + type Results = { accounts?: Account[] statuses?: Status[] diff --git a/src/components/Timeline/Notifications.tsx b/src/components/Timeline/Notifications.tsx index 4d7b69a6..7eff27d1 100644 --- a/src/components/Timeline/Notifications.tsx +++ b/src/components/Timeline/Notifications.tsx @@ -28,18 +28,18 @@ import TimelineHeaderAndroid from './Shared/HeaderAndroid' export interface Props { notification: Mastodon.Notification queryKey: QueryKeyTimeline - highlighted?: boolean } -const TimelineNotifications: React.FC = ({ - notification, - queryKey, - highlighted = false -}) => { +const TimelineNotifications: React.FC = ({ notification, queryKey }) => { const instanceAccount = useSelector(getInstanceAccount, () => true) const status = notification.status?.reblog ? notification.status.reblog : notification.status - const account = notification.status ? notification.status.account : notification.account + const account = + notification.type === 'admin.report' + ? notification.report.target_account + : notification.status + ? notification.status.account + : notification.account const ownAccount = notification.account?.id === instanceAccount?.id const [spoilerExpanded, setSpoilerExpanded] = useState( instanceAccount.preferences['reading:expand:spoilers'] || false @@ -91,7 +91,8 @@ const TimelineNotifications: React.FC = ({ notification.type === 'follow' || notification.type === 'follow_request' || notification.type === 'mention' || - notification.type === 'status' + notification.type === 'status' || + notification.type === 'admin.sign_up' ? 1 : 0.5 }} @@ -102,12 +103,7 @@ const TimelineNotifications: React.FC = ({ {notification.status ? ( - + = ({ status, ownAccount, spoilerHidden, - copiableContent, - highlighted + copiableContent }} > diff --git a/src/components/Timeline/Shared/Actioned.tsx b/src/components/Timeline/Shared/Actioned.tsx index 8d3dcb26..8e73de69 100644 --- a/src/components/Timeline/Shared/Actioned.tsx +++ b/src/components/Timeline/Shared/Actioned.tsx @@ -28,7 +28,12 @@ const TimelineActioned: React.FC = ({ action, isNotification, ...rest }) const iconColor = colors.primaryDefault const content = (content: string) => ( - + ) const onPress = () => navigation.push('Tab-Shared-Account', { account }) @@ -145,6 +150,30 @@ const TimelineActioned: React.FC = ({ action, isNotification, ...rest }) {content(t('shared.actioned.update'))} ) + case 'admin.sign_up': + return ( + <> + + {content(t('shared.actioned.admin.sign_up', { name: `@${account.acct}` }))} + + ) + case 'admin.report': + return ( + <> + + {content(t('shared.actioned.admin.report', { name: `@${account.acct}` }))} + + ) default: return <> } diff --git a/src/components/Timeline/Shared/HeaderNotification.tsx b/src/components/Timeline/Shared/HeaderNotification.tsx index a7f6c312..7b93b702 100644 --- a/src/components/Timeline/Shared/HeaderNotification.tsx +++ b/src/components/Timeline/Shared/HeaderNotification.tsx @@ -1,13 +1,19 @@ +import Button from '@components/Button' import menuAccount from '@components/contextMenu/account' import menuInstance from '@components/contextMenu/instance' import menuShare from '@components/contextMenu/share' import menuStatus from '@components/contextMenu/status' import Icon from '@components/Icon' import { RelationshipIncoming, RelationshipOutgoing } from '@components/Relationship' +import browserPackage from '@helpers/browserPackage' +import { getInstanceUrl } from '@utils/slices/instancesSlice' import { StyleConstants } from '@utils/styles/constants' import { useTheme } from '@utils/styles/ThemeManager' +import * as WebBrowser from 'expo-web-browser' import React, { useContext, useState } from 'react' +import { useTranslation } from 'react-i18next' import { Platform, Pressable, View } from 'react-native' +import { useSelector } from 'react-redux' import * as DropdownMenu from 'zeego/dropdown-menu' import StatusContext from './Context' import HeaderSharedAccount from './HeaderShared/Account' @@ -21,6 +27,7 @@ export type Props = { } const TimelineHeaderNotification: React.FC = ({ notification }) => { + const { t } = useTranslation('componentTimeline') const { queryKey, status } = useContext(StatusContext) const { colors } = useTheme() @@ -40,12 +47,32 @@ const TimelineHeaderNotification: React.FC = ({ notification }) => { const mStatus = menuStatus({ status, queryKey }) const mInstance = menuInstance({ status, queryKey }) + const url = useSelector(getInstanceUrl) + const actions = () => { switch (notification.type) { case 'follow': return case 'follow_request': return + case 'admin.report': + return ( +