Fix notification bell toast
This commit is contained in:
parent
af7b553da3
commit
4bd5beb2f6
2 changed files with 17 additions and 23 deletions
|
@ -16,9 +16,8 @@ type SubscriptionArgs = {
|
|||
type Props = {
|
||||
permanentUrl: ?string,
|
||||
isSubscribed: boolean,
|
||||
doChannelSubscribe: (SubscriptionArgs) => void,
|
||||
doChannelUnsubscribe: (SubscriptionArgs) => void,
|
||||
showSnackBarOnSubscribe: boolean,
|
||||
doChannelSubscribe: (SubscriptionArgs, boolean) => void,
|
||||
doChannelUnsubscribe: (SubscriptionArgs, boolean) => void,
|
||||
doToast: ({ message: string }) => void,
|
||||
shrinkOnMobile: boolean,
|
||||
notificationsDisabled: boolean,
|
||||
|
@ -32,7 +31,6 @@ export default function SubscribeButton(props: Props) {
|
|||
doChannelSubscribe,
|
||||
doChannelUnsubscribe,
|
||||
isSubscribed,
|
||||
showSnackBarOnSubscribe,
|
||||
doToast,
|
||||
shrinkOnMobile = false,
|
||||
notificationsDisabled,
|
||||
|
@ -78,7 +76,7 @@ export default function SubscribeButton(props: Props) {
|
|||
channelName: '@' + rawChannelName,
|
||||
uri: uri,
|
||||
notificationsDisabled: true,
|
||||
});
|
||||
}, true);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
@ -103,11 +101,7 @@ export default function SubscribeButton(props: Props) {
|
|||
channelName: claimName,
|
||||
uri: permanentUrl,
|
||||
notificationsDisabled: true,
|
||||
});
|
||||
|
||||
if (showSnackBarOnSubscribe) {
|
||||
doToast({ message: __('Now following %channel%!', { channel: claimName }) });
|
||||
}
|
||||
}, true);
|
||||
}}
|
||||
/>
|
||||
{isSubscribed && uiNotificationsEnabled && (
|
||||
|
@ -122,11 +116,10 @@ export default function SubscribeButton(props: Props) {
|
|||
channelName: claimName,
|
||||
uri: permanentUrl,
|
||||
notificationsDisabled: newNotificationsDisabled,
|
||||
});
|
||||
}, false);
|
||||
|
||||
if (newNotificationsDisabled === false) {
|
||||
doToast({ message: __('Notifications turned on for %channel%!', { channel: claimName }) });
|
||||
}
|
||||
doToast({ message: __(newNotificationsDisabled ? 'Notifications turned off for %channel%' : 'Notifications turned on for %channel%!',
|
||||
{ channel: claimName }) });
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
|
|
@ -13,7 +13,7 @@ type SubscriptionArgs = {
|
|||
notificationsDisabled?: boolean,
|
||||
};
|
||||
|
||||
export function doToggleSubscription(subscription: SubscriptionArgs, isSubscribed: boolean = false) {
|
||||
export function doToggleSubscription(subscription: SubscriptionArgs, followToast: boolean, isSubscribed: boolean = false) {
|
||||
return async (dispatch: Dispatch, getState: GetState) => {
|
||||
const {
|
||||
settings: { daemonSettings },
|
||||
|
@ -58,21 +58,22 @@ export function doToggleSubscription(subscription: SubscriptionArgs, isSubscribe
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(doToast({
|
||||
message: __(!isSubscribed ? 'You followed %CHANNEL_NAME%!' : 'Unfollowed %CHANNEL_NAME%.', { CHANNEL_NAME: subscription.channelName }),
|
||||
}));
|
||||
if (followToast) {
|
||||
dispatch(doToast({
|
||||
message: __(!isSubscribed ? 'You followed %CHANNEL_NAME%!' : 'Unfollowed %CHANNEL_NAME%.', { CHANNEL_NAME: subscription.channelName }),
|
||||
}));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function doChannelSubscribe(subscription: SubscriptionArgs) {
|
||||
export function doChannelSubscribe(subscription: SubscriptionArgs, followToast: boolean = true) {
|
||||
return (dispatch: Dispatch) => {
|
||||
return dispatch(doToggleSubscription(subscription));
|
||||
return dispatch(doToggleSubscription(subscription, followToast));
|
||||
};
|
||||
}
|
||||
|
||||
export function doChannelUnsubscribe(subscription: SubscriptionArgs) {
|
||||
export function doChannelUnsubscribe(subscription: SubscriptionArgs, followToast: boolean = true) {
|
||||
return (dispatch: Dispatch) => {
|
||||
return dispatch(doToggleSubscription(subscription, true));
|
||||
return dispatch(doToggleSubscription(subscription, followToast, true));
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue