mobile: fix handling invalid gift code

This commit is contained in:
Ammar Ahmed
2026-05-06 12:03:20 +05:00
parent 63076d37f5
commit 5ef3bdcad4
4 changed files with 20 additions and 3 deletions

View File

@@ -238,13 +238,21 @@ export const settingsGroups: SettingSection[] = [
inputPlaceholder: strings.code(),
positiveText: strings.redeem(),
positivePress: async (value) => {
db.subscriptions.redeemCode(value).catch((e) => {
try {
if (!value || !value.trim()) {
throw new Error(strings.giftCodeRequired());
}
await db.subscriptions.redeemCode(value);
return true;
} catch (e) {
ToastManager.show({
heading: "Error redeeming code",
message: (e as Error).message,
type: "error"
});
});
return false;
}
}
});
}

View File

@@ -3101,6 +3101,10 @@ msgstr "Getting information"
msgid "Getting recovery codes"
msgstr "Getting recovery codes"
#: src/strings.ts:2663
msgid "Gift code required"
msgstr "Gift code required"
#: src/strings.ts:2172
msgid "GNU GENERAL PUBLIC LICENSE Version 3"
msgstr "GNU GENERAL PUBLIC LICENSE Version 3"

View File

@@ -3083,6 +3083,10 @@ msgstr ""
msgid "Getting recovery codes"
msgstr ""
#: src/strings.ts:2663
msgid "Gift code required"
msgstr ""
#: src/strings.ts:2172
msgid "GNU GENERAL PUBLIC LICENSE Version 3"
msgstr ""

View File

@@ -2659,5 +2659,6 @@ Use this if changes from other devices are not appearing on this device. This wi
t`Value must be between ${min} and ${max}`,
passwordRequired: () => t`Password required`,
confirmPasswordRequired: () => t`Confirm password required`,
enterAValidEmailAddress: () => t`Please enter a valid email address`
enterAValidEmailAddress: () => t`Please enter a valid email address`,
giftCodeRequired: () => t`Gift code required`
};