Skip to content

Commit

Permalink
ServerPushSetupBanner: "Learn more" dismisses banner, opens "Notifica…
Browse files Browse the repository at this point in the history
…tions"

Fixes-partly: zulip#5785
  • Loading branch information
chrisbobbe committed Jan 4, 2024
1 parent 38882d8 commit f2d056b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions src/common/ServerPushSetupBanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import type { Node } from 'react';
import subWeeks from 'date-fns/subWeeks';

import ZulipBanner from './ZulipBanner';
import { useSelector, useGlobalSelector, useDispatch } from '../react-redux';
import { useSelector, useDispatch } from '../react-redux';
import { getAccount } from '../account/accountsSelectors';
import { getRealm, getGlobalSettings } from '../directSelectors';
import { getRealm } from '../directSelectors';
import { getRealmName } from '../selectors';
import { dismissServerPushSetupNotice } from '../account/accountActions';
import { openLinkWithUserPreference } from '../utils/openLink';
import {
NotificationProblem,
notifProblemShortReactText,
} from '../settings/NotifTroubleshootingScreen';
import type { AppNavigationMethods } from '../nav/AppNavigator';

type Props = $ReadOnly<{||}>;
type Props = $ReadOnly<{|
navigation: AppNavigationMethods,
|}>;

/**
* A "nag banner" saying the server hasn't enabled push notifications, if so
Expand All @@ -28,14 +30,15 @@ type Props = $ReadOnly<{||}>;
* un-setup, a new notice will apply.)
*/
export default function ServerPushSetupBanner(props: Props): Node {
const { navigation } = props;

const dispatch = useDispatch();

const lastDismissedServerPushSetupNotice = useSelector(
state => getAccount(state).lastDismissedServerPushSetupNotice,
);
const pushNotificationsEnabled = useSelector(state => getRealm(state).pushNotificationsEnabled);
const realmName = useSelector(getRealmName);
const settings = useGlobalSelector(getGlobalSettings);

let visible = false;
let text = '';
Expand Down Expand Up @@ -65,12 +68,8 @@ export default function ServerPushSetupBanner(props: Props): Node {
id: 'learn-more',
label: 'Learn more',
onPress: () => {
openLinkWithUserPreference(
new URL(
'https://zulip.com/help/mobile-notifications#enabling-push-notifications-for-self-hosted-servers',
),
settings,
);
dispatch(dismissServerPushSetupNotice());
navigation.push('notifications');
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/main/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default function HomeScreen(props: Props): Node {
/>
</View>
<ServerCompatBanner />
<ServerPushSetupBanner />
<ServerPushSetupBanner navigation={navigation} />
<LoadingBanner />
<UnreadCards />
</SafeAreaView>
Expand Down

0 comments on commit f2d056b

Please sign in to comment.