From 3ec6800a3496f3e942acdf5e5036fa659e34f8e2 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 18 Oct 2023 11:53:54 -0300 Subject: [PATCH] feat: add troubleshooting to notifications pages (#5276) * feat: add troubleshooting to notifications pages * fix e2e test --- app/i18n/locales/en.json | 3 +- .../NotificationPreferencesView/index.tsx | 23 ++++++++++++-- .../UserNotificationPreferencesView/index.tsx | 30 +++++++++++++++++-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index e5bf1b504..26acda714 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -769,5 +769,6 @@ "Jitsi_authentication_before_making_calls_admin": "Jitsi may require authentication before making calls. To learn more about their policies, visit the Jitsi website. You can also update the default app for video calls in the preferences.", "Jitsi_authentication_before_making_calls": "Jitsi may require authentication before making calls. To learn more about their policies, visit the Jitsi website.", "Jitsi_authentication_before_making_calls_ask_admin": "If you believe there are problems with Jitsi and its authentication, ask a workspace administrator for help.", - "Continue": "Continue" + "Continue": "Continue", + "Troubleshooting": "Troubleshooting" } diff --git a/app/views/NotificationPreferencesView/index.tsx b/app/views/NotificationPreferencesView/index.tsx index 176b81c1e..94efb064d 100644 --- a/app/views/NotificationPreferencesView/index.tsx +++ b/app/views/NotificationPreferencesView/index.tsx @@ -1,6 +1,7 @@ import { RouteProp, useNavigation, useRoute } from '@react-navigation/core'; import React, { useEffect, useState } from 'react'; import { Switch, Text } from 'react-native'; +import { StackNavigationProp } from '@react-navigation/stack'; import { TActionSheetOptionsItem, useActionSheet } from '../../containers/ActionSheet'; import { CustomIcon } from '../../containers/CustomIcon'; @@ -91,8 +92,11 @@ const RenderSwitch = ({ preference, room, onChangeValue }: IBaseParams) => { const NotificationPreferencesView = (): React.ReactElement => { const route = useRoute>(); const { rid, room } = route.params; - const navigation = useNavigation(); - const serverVersion = useAppSelector(state => state.server.version); + const navigation = useNavigation>(); + const { serverVersion, isMasterDetail } = useAppSelector(state => ({ + serverVersion: state.server.version, + isMasterDetail: state.app.isMasterDetail + })); const [hideUnreadStatus, setHideUnreadStatus] = useState(room.hideUnreadStatus); useEffect(() => { @@ -108,6 +112,14 @@ const NotificationPreferencesView = (): React.ReactElement => { }); }, []); + const goPushTroubleshoot = () => { + if (isMasterDetail) { + navigation.navigate('ModalStackNavigator', { screen: 'PushTroubleshootView' }); + } else { + navigation.navigate('PushTroubleshootView'); + } + }; + const saveNotificationSettings = async (key: TUnionOptionsRoomNotifications, params: IRoomNotifications, onError: Function) => { try { // @ts-ignore @@ -202,6 +214,13 @@ const NotificationPreferencesView = (): React.ReactElement => { onChangeValue={saveNotificationSettings} /> + + diff --git a/app/views/UserNotificationPreferencesView/index.tsx b/app/views/UserNotificationPreferencesView/index.tsx index 1dcfc5fe4..7473d278f 100644 --- a/app/views/UserNotificationPreferencesView/index.tsx +++ b/app/views/UserNotificationPreferencesView/index.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useLayoutEffect, useState } from 'react'; import { StackNavigationProp } from '@react-navigation/stack'; -import { useNavigation } from '@react-navigation/native'; +import { CompositeNavigationProp, useNavigation } from '@react-navigation/native'; import StatusBar from '../../containers/StatusBar'; import * as List from '../../containers/List'; @@ -14,13 +14,22 @@ import { Services } from '../../lib/services'; import { useAppSelector } from '../../lib/hooks'; import ListPicker from './ListPicker'; import log from '../../lib/methods/helpers/log'; +import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types'; + +type TNavigation = CompositeNavigationProp< + StackNavigationProp, + StackNavigationProp +>; const UserNotificationPreferencesView = () => { const [preferences, setPreferences] = useState({} as INotificationPreferences); const [loading, setLoading] = useState(true); - const navigation = useNavigation>(); - const userId = useAppSelector(state => getUserSelector(state).id); + const navigation = useNavigation(); + const { userId, isMasterDetail } = useAppSelector(state => ({ + userId: getUserSelector(state).id, + isMasterDetail: state.app.isMasterDetail + })); useLayoutEffect(() => { navigation.setOptions({ @@ -58,6 +67,14 @@ const UserNotificationPreferencesView = () => { } }; + const goPushTroubleshoot = () => { + if (isMasterDetail) { + navigation.navigate('ModalStackNavigator', { screen: 'PushTroubleshootView' }); + } else { + navigation.navigate('PushTroubleshootView'); + } + }; + return ( @@ -89,6 +106,13 @@ const UserNotificationPreferencesView = () => { value={preferences.pushNotifications} /> + +