From 08f3036753e9486569ab2381955f71efd9a9bc79 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 24 Jan 2021 02:25:43 +0100 Subject: [PATCH] Updates --- app.config.ts | 3 +- demo/statuses.json | 97 +++++++++++-- src/@types/react-navigation.d.ts | 23 ++- src/Index.tsx | 8 +- src/components/Account.tsx | 24 +++- src/components/BottomSheet.tsx | 7 +- src/components/Hashtag.tsx | 28 +++- src/components/Instance.tsx | 9 +- src/components/Parse/HTML.tsx | 16 ++- src/components/Relationship/Incoming.tsx | 11 +- src/components/Relationship/Outgoing.tsx | 28 +++- src/components/Timelines.tsx | 2 + src/components/Timelines/Timeline.tsx | 24 ++-- .../Timelines/Timeline/Conversation.tsx | 48 ++++++- src/components/Timelines/Timeline/Default.tsx | 39 +++-- src/components/Timelines/Timeline/Empty.tsx | 6 +- src/components/Timelines/Timeline/Header.tsx | 2 + .../Timelines/Timeline/Notifications.tsx | 22 ++- .../Timelines/Timeline/Shared/Actioned.tsx | 7 +- .../Timelines/Timeline/Shared/Actions.tsx | 134 ++++++++++-------- .../Timelines/Timeline/Shared/Attachment.tsx | 7 +- .../Timeline/Shared/Attachment/Audio.tsx | 3 + .../Timeline/Shared/Attachment/Image.tsx | 6 +- .../Shared/Attachment/Unsupported.tsx | 6 +- .../Timeline/Shared/Attachment/Video.tsx | 12 ++ .../Timelines/Timeline/Shared/Avatar.tsx | 7 +- .../Timelines/Timeline/Shared/Card.tsx | 22 ++- .../Timeline/Shared/HeaderActions/Account.tsx | 32 ++++- .../Timeline/Shared/HeaderActions/Domain.tsx | 10 ++ .../Timeline/Shared/HeaderActions/Root.tsx | 8 +- .../Timeline/Shared/HeaderActions/Share.tsx | 7 +- .../Timeline/Shared/HeaderActions/Status.tsx | 68 +++++---- .../Timeline/Shared/HeaderConversation.tsx | 54 +++++-- .../Timeline/Shared/HeaderDefault.tsx | 2 +- .../Timeline/Shared/HeaderShared/Account.tsx | 2 +- .../Shared/HeaderShared/Application.tsx | 8 +- .../Timelines/Timeline/Shared/Poll.tsx | 13 +- src/components/analytics.ts | 2 +- src/i18n/en/common.ts | 3 + src/i18n/en/components/timeline.ts | 1 + src/i18n/zh-Hans/common.ts | 3 + src/i18n/zh-Hans/components/timeline.ts | 3 +- src/screens/Me/Lists.tsx | 8 -- src/screens/Me/Root/MyInfo.tsx | 2 +- src/screens/Me/Settings.tsx | 39 ++++- src/screens/Me/Switch.tsx | 6 +- src/screens/Me/Switch/Root.tsx | 2 + src/screens/Notifications.tsx | 2 +- src/screens/Shared/Account.tsx | 8 +- src/screens/Shared/Account/Attachments.tsx | 19 ++- src/screens/Shared/Account/Information.tsx | 25 ++-- .../Shared/Account/Information/Account.tsx | 13 +- .../Shared/Account/Information/Actions.tsx | 39 +++-- .../Shared/Account/Information/Avatar.tsx | 31 +++- .../Shared/Account/Information/Stats.tsx | 33 +++-- src/screens/Shared/Announcements.tsx | 21 +-- src/screens/Shared/Compose.tsx | 37 +++-- src/screens/Shared/Compose/EditAttachment.tsx | 2 + src/screens/Shared/Compose/Root/Actions.tsx | 49 +++++-- .../Compose/Root/Footer/Attachments.tsx | 34 +++-- .../Shared/Compose/Root/Footer/Emojis.tsx | 2 + .../Shared/Compose/Root/Footer/Poll.tsx | 39 +++-- .../Compose/Root/Footer/addAttachment.ts | 27 +++- src/screens/Shared/Compose/Root/Header.tsx | 7 +- .../Shared/Compose/Root/Header/PostingAs.tsx | 47 +++--- .../Shared/Compose/Root/Suggestion.tsx | 8 +- .../Shared/Compose/utils/parseState.ts | 47 +++--- src/screens/Shared/ImagesViewer.tsx | 11 +- src/screens/Shared/Relationships/List.tsx | 14 +- src/screens/Shared/Search.tsx | 26 +--- src/startup/netInfo.ts | 2 +- src/startup/sentry.ts | 1 + 72 files changed, 978 insertions(+), 440 deletions(-) diff --git a/app.config.ts b/app.config.ts index 00bdddb0..ba65cc02 100644 --- a/app.config.ts +++ b/app.config.ts @@ -19,7 +19,8 @@ export default (): ExpoConfig => ({ scheme: 'tooot', assetBundlePatterns: ['assets/*'], extra: { - sentryDSN: process.env.SENTRY_DSN + sentryDSN: process.env.SENTRY_DSN, + sentryEnv: process.env.SENTRY_DEPLOY_ENV }, hooks: { postPublish: [ diff --git a/demo/statuses.json b/demo/statuses.json index 2c654588..6979abe3 100644 --- a/demo/statuses.json +++ b/demo/statuses.json @@ -3,7 +3,7 @@ "pages": [ [ { - "id": "1", + "id": "999", "created_at": "2021-01-22T03:48:33.901Z", "sensitive": false, "visibility": "public", @@ -21,17 +21,38 @@ "website": "https://tooot.app" }, "account": { - "id": "1", + "id": "999", "username": "tooot📱", "acct": "tooot@xmflsct.com", "display_name": "tooot📱", "avatar_static": "https://avatars.githubusercontent.com/u/77554750?s=200&v=4" }, "media_attachments": [], - "poll": null + "poll": { + "id": "1", + "expires_at": "2021-02-22T03:48:33.901Z", + "expired": false, + "multiple": false, + "votes_count": 10, + "voters_count": null, + "voted": false, + "own_votes": null, + "options": [ + { + "title": "I would love to!", + "votes_count": 6 + }, + { + "title": "Why not give it a go?", + "votes_count": 4 + } + ], + "emojis": [] + }, + "mentions": [] }, { - "id": "2", + "id": "1000", "created_at": "2021-01-22T03:48:33.901Z", "sensitive": false, "spoiler_text": "", @@ -50,7 +71,7 @@ "website": null }, "account": { - "id": "2", + "id": "1000", "username": "Mastodon", "acct": "mastodon", "display_name": "Mastodon", @@ -63,10 +84,11 @@ "description": "Mastodon is an open source decentralized social network - by the people for the people. Join the federation and take back control of your social media!", "type": "link", "image": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Mastodon_Logotype_%28Simple%29.svg/1200px-Mastodon_Logotype_%28Simple%29.svg.png" - } + }, + "mentions": [] }, { - "id": "3", + "id": "1001", "created_at": "2021-01-22T03:48:33.901Z", "spoiler_text": "", "visibility": "public", @@ -84,13 +106,70 @@ "website": null }, "account": { - "id": "3", + "id": "1001", "username": "Fediverse", "acct": "fediverse", "display_name": "Fediverse", "avatar_static": "https://e7.pngegg.com/pngimages/667/514/png-clipart-mastodon-fediverse-social-media-free-software-logo-social-media-blue-text.png" }, - "media_attachments": [] + "media_attachments": [], + "mentions": [] + }, + { + "id": "1002", + "created_at": "2021-01-22T03:48:33.901Z", + "sensitive": false, + "visibility": "public", + "replies_count": 0, + "reblogs_count": 0, + "favourites_count": 0, + "favourited": true, + "reblogged": false, + "muted": false, + "bookmarked": false, + "content": "

tooot is an open source, simple mobile client for Mastodon. Focusing on your connections while being able to explore the Fediverse.

", + "reblog": null, + "application": { + "name": "tooot", + "website": "https://tooot.app" + }, + "account": { + "id": "1002", + "username": "tooot📱", + "acct": "tooot@xmflsct.com", + "display_name": "tooot📱", + "avatar_static": "https://avatars.githubusercontent.com/u/77554750?s=200&v=4" + }, + "media_attachments": [], + "mentions": [] + }, + { + "id": "1003", + "created_at": "2021-01-22T03:48:33.901Z", + "sensitive": false, + "visibility": "public", + "replies_count": 0, + "reblogs_count": 0, + "favourites_count": 0, + "favourited": true, + "reblogged": false, + "muted": false, + "bookmarked": false, + "content": "

- tooot supports multiple accounts
- tooot supports browsing external instance
- tooot aims to support multiple languages

", + "reblog": null, + "application": { + "name": "tooot", + "website": "https://tooot.app" + }, + "account": { + "id": "1003", + "username": "tooot📱", + "acct": "tooot@xmflsct.com", + "display_name": "tooot📱", + "avatar_static": "https://avatars.githubusercontent.com/u/77554750?s=200&v=4" + }, + "media_attachments": [], + "mentions": [] } ] ] diff --git a/src/@types/react-navigation.d.ts b/src/@types/react-navigation.d.ts index cb805e10..23c36e7e 100644 --- a/src/@types/react-navigation.d.ts +++ b/src/@types/react-navigation.d.ts @@ -9,13 +9,13 @@ declare namespace Nav { type SharedStackParamList = { 'Screen-Shared-Account': { - account: Pick + account: Mastodon.Account | Mastodon.Mention } 'Screen-Shared-Announcements': { showAll?: boolean } 'Screen-Shared-Attachments': { account: Mastodon.Account } 'Screen-Shared-Compose': | { - type: 'reply' | 'conversation' | 'edit' + type: 'edit' incomingStatus: Mastodon.Status queryKey?: [ 'Timeline', @@ -28,6 +28,25 @@ declare namespace Nav { } ] } + | { + type: 'reply' + incomingStatus: Mastodon.Status + accts: Mastodon.Account['acct'][] + queryKey?: [ + 'Timeline', + { + page: App.Pages + hashtag?: Mastodon.Tag['name'] + list?: Mastodon.List['id'] + toot?: Mastodon.Status['id'] + account?: Mastodon.Account['id'] + } + ] + } + | { + type: 'conversation' + accts: Mastodon.Account['acct'][] + } | undefined 'Screen-Shared-Hashtag': { hashtag: Mastodon.Tag['name'] diff --git a/src/Index.tsx b/src/Index.tsx index 97973e4e..acf7a80e 100644 --- a/src/Index.tsx +++ b/src/Index.tsx @@ -33,6 +33,7 @@ import React, { useMemo, useRef } from 'react' +import { useTranslation } from 'react-i18next' import { Image, Platform, StatusBar } from 'react-native' import Toast from 'react-native-toast-message' import { useDispatch, useSelector } from 'react-redux' @@ -70,11 +71,12 @@ const Index: React.FC = ({ localCorrupt }) => { // }, [isConnected, firstRender]) // On launch display login credentials corrupt information + const { t } = useTranslation('common') useEffect(() => { const showLocalCorrect = localCorrupt ? toast({ type: 'error', - message: '登录已过期', + message: t('index.localCorrupt'), description: localCorrupt.length ? localCorrupt : undefined, autoHide: false }) @@ -193,8 +195,8 @@ const Index: React.FC = ({ localCorrupt }) => { void + onPress?: () => void + origin?: string } -const ComponentAccount: React.FC = ({ account, onPress }) => { +const ComponentAccount: React.FC = ({ + account, + onPress: customOnPress, + origin +}) => { const { theme } = useTheme() + const navigation = useNavigation< + StackNavigationProp + >() + + const onPress = useCallback(() => { + analytics('search_account_press', { page: origin }) + navigation.push('Screen-Shared-Account', { account }) + }, []) return ( = ({ children, visible, handleDismiss }) => { } }) const callDismiss = () => { + analytics('bottomsheet_swipe_close') handleDismiss() } const onGestureEvent = useAnimatedGestureHandler({ @@ -90,7 +92,10 @@ const BottomSheet: React.FC = ({ children, visible, handleDismiss }) => {