mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
Donations: show modal when we can't apply the user's badge
This commit is contained in:
@@ -9054,6 +9054,14 @@
|
||||
"messageformat": "Donation succeeded, but we could not update your badge settings",
|
||||
"description": "Toast shown when donation completes successfully but badge application fails"
|
||||
},
|
||||
"icu:Donations__BadgeApplicationFailed__Title": {
|
||||
"messageformat": "Donation succeeded, but we could not update your badge settings",
|
||||
"description": "Modal title shown when donation completes successfully but badge application fails"
|
||||
},
|
||||
"icu:Donations__BadgeApplicationFailed__Description": {
|
||||
"messageformat": "To update your badge settings on your mobile device, go to Settings → Donate to Signal → Badges.",
|
||||
"description": "Modal body text shown when badge application fails after successful donation"
|
||||
},
|
||||
"icu:Donations__DonationInterrupted": {
|
||||
"messageformat": "Donation interrupted",
|
||||
"description": "Title of the dialog shown when starting up if a donation had been started, and we've saved payment information, but the charge hasn't happened yet"
|
||||
|
||||
@@ -45,6 +45,11 @@ export function DonationErrorModal(props: PropsType): JSX.Element {
|
||||
body = i18n('icu:Donations__TimedOut__Description');
|
||||
break;
|
||||
}
|
||||
case donationErrorTypeSchema.Enum.BadgeApplicationFailed: {
|
||||
title = i18n('icu:Donations__BadgeApplicationFailed__Title');
|
||||
body = i18n('icu:Donations__BadgeApplicationFailed__Description');
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw missingCaseError(props.errorType);
|
||||
|
||||
@@ -628,6 +628,12 @@ export function PreferencesDonations({
|
||||
i18n={i18n}
|
||||
onClose={() => {
|
||||
setIsSubmitted(false);
|
||||
if (
|
||||
workflow?.type === 'DONE' &&
|
||||
lastError === donationErrorTypeSchema.Enum.BadgeApplicationFailed
|
||||
) {
|
||||
clearWorkflow();
|
||||
}
|
||||
updateLastError(undefined);
|
||||
}}
|
||||
/>
|
||||
@@ -675,13 +681,13 @@ export function PreferencesDonations({
|
||||
badge={donationBadge}
|
||||
applyDonationBadge={applyDonationBadge}
|
||||
onClose={(error?: Error) => {
|
||||
clearWorkflow();
|
||||
if (error) {
|
||||
log.error('Badge application failed:', error.message);
|
||||
showToast({
|
||||
toastType: ToastType.DonationCompletedAndBadgeApplicationFailed,
|
||||
});
|
||||
updateLastError(
|
||||
donationErrorTypeSchema.Enum.BadgeApplicationFailed
|
||||
);
|
||||
} else {
|
||||
clearWorkflow();
|
||||
showToast({
|
||||
toastType: ToastType.DonationCompleted,
|
||||
});
|
||||
|
||||
@@ -41,10 +41,6 @@ function getToast(toastType: ToastType): AnyToast {
|
||||
};
|
||||
case ToastType.Blocked:
|
||||
return { toastType: ToastType.Blocked };
|
||||
case ToastType.DonationCompletedAndBadgeApplicationFailed:
|
||||
return {
|
||||
toastType: ToastType.DonationCompletedAndBadgeApplicationFailed,
|
||||
};
|
||||
case ToastType.BlockedGroup:
|
||||
return { toastType: ToastType.BlockedGroup };
|
||||
case ToastType.CallHistoryCleared:
|
||||
|
||||
@@ -118,16 +118,6 @@ export function renderToast({
|
||||
);
|
||||
}
|
||||
|
||||
if (toastType === ToastType.DonationCompletedAndBadgeApplicationFailed) {
|
||||
return (
|
||||
<Toast onClose={hideToast}>
|
||||
{i18n(
|
||||
'icu:Donations__Toast__DonationCompletedAndBadgeApplicationFailed'
|
||||
)}
|
||||
</Toast>
|
||||
);
|
||||
}
|
||||
|
||||
if (toastType === ToastType.Blocked) {
|
||||
return <Toast onClose={hideToast}>{i18n('icu:unblockToSend')}</Toast>;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,8 @@ export const donationErrorTypeSchema = z.enum([
|
||||
'PaymentDeclined',
|
||||
// When it's been too long since the last step of the donation, and card wasn't charged
|
||||
'TimedOut',
|
||||
// When donation succeeds but badge application fails
|
||||
'BadgeApplicationFailed',
|
||||
]);
|
||||
export type DonationErrorType = z.infer<typeof donationErrorTypeSchema>;
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ export enum ToastType {
|
||||
AlreadyRequestedToJoin = 'AlreadyRequestedToJoin',
|
||||
AttachmentDownloadFailed = 'AttachmentDownloadFailed',
|
||||
AttachmentDownloadStillInProgress = 'AttachmentDownloadStillInProgress',
|
||||
DonationCompletedAndBadgeApplicationFailed = 'DonationCompletedAndBadgeApplicationFailed',
|
||||
Blocked = 'Blocked',
|
||||
BlockedGroup = 'BlockedGroup',
|
||||
CallHistoryCleared = 'CallHistoryCleared',
|
||||
@@ -104,7 +103,6 @@ export type AnyToast =
|
||||
toastType: ToastType.AttachmentDownloadStillInProgress;
|
||||
parameters: { count: number };
|
||||
}
|
||||
| { toastType: ToastType.DonationCompletedAndBadgeApplicationFailed }
|
||||
| { toastType: ToastType.Blocked }
|
||||
| { toastType: ToastType.BlockedGroup }
|
||||
| { toastType: ToastType.CallHistoryCleared }
|
||||
|
||||
Reference in New Issue
Block a user