From 6b4c2d18ec40d75e41e3faf7e4691dd62a679c96 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 29 May 2022 01:57:15 +0200 Subject: [PATCH] Push add more types --- src/@types/mastodon.d.ts | 2 ++ src/i18n/en/screens/tabs.json | 6 ++++++ src/screens/Tabs/Me/Push.tsx | 14 ++++++++++++-- src/screens/Tabs/Me/SettingsLanguage.tsx | 4 +++- src/utils/migrations/instances/migration.ts | 14 ++++++++++++++ src/utils/migrations/instances/v10.ts | 8 ++++++++ src/utils/slices/instances/add.ts | 4 +++- 7 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/@types/mastodon.d.ts b/src/@types/mastodon.d.ts index 1a62f519..fd7ce0d7 100644 --- a/src/@types/mastodon.d.ts +++ b/src/@types/mastodon.d.ts @@ -376,10 +376,12 @@ declare namespace Mastodon { endpoint: string alerts: { follow: boolean + follow_request: boolean favourite: boolean reblog: boolean mention: boolean poll: boolean + status: boolean } server_key: string } diff --git a/src/i18n/en/screens/tabs.json b/src/i18n/en/screens/tabs.json index cb658c5d..8f652234 100644 --- a/src/i18n/en/screens/tabs.json +++ b/src/i18n/en/screens/tabs.json @@ -169,6 +169,9 @@ "follow": { "heading": "New follower" }, + "follow_request": { + "heading": "Follow request" + }, "favourite": { "heading": "Favourited" }, @@ -181,6 +184,9 @@ "poll": { "heading": "Poll updates" }, + "status": { + "heading": "Toot from subscribed users" + }, "howitworks": "Learn how routing works" }, "root": { diff --git a/src/screens/Tabs/Me/Push.tsx b/src/screens/Tabs/Me/Push.tsx index 7a172258..e49cb86e 100644 --- a/src/screens/Tabs/Me/Push.tsx +++ b/src/screens/Tabs/Me/Push.tsx @@ -73,12 +73,22 @@ const TabMePush: React.FC = () => { const alerts = useMemo(() => { return instancePush?.alerts ? ( - ['follow', 'favourite', 'reblog', 'mention', 'poll'] as [ + [ 'follow', + 'follow_request', 'favourite', 'reblog', 'mention', - 'poll' + 'poll', + 'status' + ] as [ + 'follow', + 'follow_request', + 'favourite', + 'reblog', + 'mention', + 'poll', + 'status' ] ).map(alert => ( -> = () => { +> = ({ navigation }) => { const { i18n, t } = useTranslation('screenTabs') const languages = Object.entries(LOCALES) const instances = useSelector(getInstances) @@ -72,6 +72,8 @@ const TabMeSettingsLanguage: React.FC< } }) } + + navigation.pop(1) } return ( diff --git a/src/utils/migrations/instances/migration.ts b/src/utils/migrations/instances/migration.ts index eadcf4d4..ac02bd1c 100644 --- a/src/utils/migrations/instances/migration.ts +++ b/src/utils/migrations/instances/migration.ts @@ -110,6 +110,20 @@ const instancesMigration = { ...instance.notifications_filter, status: true, update: true + }, + push: { + ...instance.push, + alerts: { + ...instance.push.alerts, + follow_request: { + loading: false, + value: true + }, + status: { + loading: false, + value: true + } + } } } }) diff --git a/src/utils/migrations/instances/v10.ts b/src/utils/migrations/instances/v10.ts index 6257a75f..db44a516 100644 --- a/src/utils/migrations/instances/v10.ts +++ b/src/utils/migrations/instances/v10.ts @@ -38,6 +38,10 @@ export type InstanceV10 = { loading: boolean value: Mastodon.PushSubscription['alerts']['follow'] } + follow_request: { + loading: boolean + value: Mastodon.PushSubscription['alerts']['follow_request'] + } favourite: { loading: boolean value: Mastodon.PushSubscription['alerts']['favourite'] @@ -54,6 +58,10 @@ export type InstanceV10 = { loading: boolean value: Mastodon.PushSubscription['alerts']['poll'] } + status: { + loading: boolean + value: Mastodon.PushSubscription['alerts']['status'] + } } keys: { auth?: string diff --git a/src/utils/slices/instances/add.ts b/src/utils/slices/instances/add.ts index 1f19bd34..a8f322ac 100644 --- a/src/utils/slices/instances/add.ts +++ b/src/utils/slices/instances/add.ts @@ -94,10 +94,12 @@ const addInstance = createAsyncThunk( decode: { loading: false, value: false }, alerts: { follow: { loading: false, value: true }, + follow_request: { loading: false, value: true }, favourite: { loading: false, value: true }, reblog: { loading: false, value: true }, mention: { loading: false, value: true }, - poll: { loading: false, value: true } + poll: { loading: false, value: true }, + status: { loading: false, value: true } }, keys: { auth: undefined, public: undefined, private: undefined } },