Merge branch 'subscription-button-no-tooltip' into 'develop'

SubscriptionButton: remove tooltip warning about web push

See merge request soapbox-pub/soapbox-fe!1618
timeline-nomemo
Alex Gleason 2022-07-11 17:15:03 +00:00
commit 70cd4148e6
1 zmienionych plików z 3 dodań i 23 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'; import React from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import { import {
@ -16,7 +16,6 @@ const messages = defineMessages({
subscribe: { id: 'account.subscribe', defaultMessage: 'Subscribe to notifications from @{name}' }, subscribe: { id: 'account.subscribe', defaultMessage: 'Subscribe to notifications from @{name}' },
unsubscribe: { id: 'account.unsubscribe', defaultMessage: 'Unsubscribe to notifications from @{name}' }, unsubscribe: { id: 'account.unsubscribe', defaultMessage: 'Unsubscribe to notifications from @{name}' },
subscribeSuccess: { id: 'account.subscribe.success', defaultMessage: 'You have subscribed to this account.' }, subscribeSuccess: { id: 'account.subscribe.success', defaultMessage: 'You have subscribed to this account.' },
subscribeSuccessNotice: { id: 'account.subscribe.successNotice', defaultMessage: 'You have subscribed to this account, but your web notifications are disabled. Please enable them to receive notifications from @{name}.' },
unsubscribeSuccess: { id: 'account.unsubscribe.success', defaultMessage: 'You have unsubscribed from this account.' }, unsubscribeSuccess: { id: 'account.unsubscribe.success', defaultMessage: 'You have unsubscribed from this account.' },
subscribeFailure: { id: 'account.subscribe.failure', defaultMessage: 'An error occurred trying to subscribed to this account.' }, subscribeFailure: { id: 'account.subscribe.failure', defaultMessage: 'An error occurred trying to subscribed to this account.' },
unsubscribeFailure: { id: 'account.unsubscribe.failure', defaultMessage: 'An error occurred trying to unsubscribed to this account.' }, unsubscribeFailure: { id: 'account.unsubscribe.failure', defaultMessage: 'An error occurred trying to unsubscribed to this account.' },
@ -31,14 +30,6 @@ const SubscriptionButton = ({ account }: ISubscriptionButton) => {
const features = useFeatures(); const features = useFeatures();
const intl = useIntl(); const intl = useIntl();
const [hasWebNotificationsEnabled, setWebNotificationsEnabled] = useState<boolean>(true);
const checkWebNotifications = () => {
Notification.requestPermission()
.then((value) => setWebNotificationsEnabled(value === 'granted'))
.catch(() => null);
};
const isFollowing = account.relationship?.following; const isFollowing = account.relationship?.following;
const isRequested = account.relationship?.requested; const isRequested = account.relationship?.requested;
const isSubscribed = features.accountNotifies ? const isSubscribed = features.accountNotifies ?
@ -48,13 +39,8 @@ const SubscriptionButton = ({ account }: ISubscriptionButton) => {
intl.formatMessage(messages.unsubscribe, { name: account.get('username') }) : intl.formatMessage(messages.unsubscribe, { name: account.get('username') }) :
intl.formatMessage(messages.subscribe, { name: account.get('username') }); intl.formatMessage(messages.subscribe, { name: account.get('username') });
const onSubscribeSuccess = () => { const onSubscribeSuccess = () =>
if (hasWebNotificationsEnabled) { dispatch(snackbar.success(intl.formatMessage(messages.subscribeSuccess)));
dispatch(snackbar.success(intl.formatMessage(messages.subscribeSuccess)));
} else {
dispatch(snackbar.info(intl.formatMessage(messages.subscribeSuccessNotice, { name: account.get('username') })));
}
};
const onSubscribeFailure = () => const onSubscribeFailure = () =>
dispatch(snackbar.error(intl.formatMessage(messages.subscribeFailure))); dispatch(snackbar.error(intl.formatMessage(messages.subscribeFailure)));
@ -97,12 +83,6 @@ const SubscriptionButton = ({ account }: ISubscriptionButton) => {
} }
}; };
useEffect(() => {
if (features.accountSubscriptions || features.accountNotifies) {
checkWebNotifications();
}
}, []);
if (!features.accountSubscriptions && !features.accountNotifies) { if (!features.accountSubscriptions && !features.accountNotifies) {
return null; return null;
} }