Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

mobile: add error message for incomplete theme files

kashaf-ansari-dev46b6888ca393
diff --git a/apps/mobile/app/common/filesystem/utils.ts b/apps/mobile/app/common/filesystem/utils.ts
index 6998fd68f..e5f87a39e 100644
--- a/apps/mobile/app/common/filesystem/utils.ts
+++ b/apps/mobile/app/common/filesystem/utils.ts
@@ -192,7 +192,8 @@ export async function checkAndCreateDir(path: string) {
}
export const santizeUri = (uri: string) => {
- return Platform.OS === "ios" ? decodeURI(uri).replace("file:///", "/") : uri;
+ const decoded = decodeURI(uri);
+ return Platform.OS === "ios" ? decoded.replace("file:///", "/") : decoded;
};
export function isSuccessStatusCode(statusCode: number) {
diff --git a/apps/mobile/app/screens/settings/theme-selector.tsx b/apps/mobile/app/screens/settings/theme-selector.tsx
index 72773b645..c479ce9d0 100644
--- a/apps/mobile/app/screens/settings/theme-selector.tsx
+++ b/apps/mobile/app/screens/settings/theme-selector.tsx
@@ -460,8 +460,27 @@ function ThemeSelector() {
return;
}
const result = validateTheme(json);
+
if (result.error) {
- ToastManager.error(new Error(result.error));
+ if (
+ typeof result.error === "string" &&
+ result.error.includes("missing from the theme")
+ ) {
+ ToastManager.show({
+ heading: strings.themeMissingRequiredFields(),
+ type: "error",
+ context: "global",
+ actionText: strings.learnMore(),
+ func: () => {
+ openLinkInBrowser(
+ "https://help.notesnook.com/custom-themes/introduction"
+ );
+ }
+ });
+ } else {
+ ToastManager.error(new Error(result.error));
+ }
+
return;
}
select(json, true);
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 5d891aeb7..2c0ed85e4 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -7277,6 +7277,10 @@ msgstr "We are sorry, it seems that the app crashed due to an error. You can sub
msgid "We couldn't load this theme. Please make sure the file is a valid JSON theme file."
msgstr "We couldn't load this theme. Please make sure the file is a valid JSON theme file."
+#: src/strings.ts:2693
+msgid "We couldn't load this theme. The file appears to be incomplete or missing required theme properties."
+msgstr "We couldn't load this theme. The file appears to be incomplete or missing required theme properties."
+
#: src/strings.ts:1390
msgid "We have sent you an email confirmation link. Please check your email inbox. If you cannot find the email, check your spam folder."
msgstr "We have sent you an email confirmation link. Please check your email inbox. If you cannot find the email, check your spam folder."
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 64969b285..89b9590d1 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -7227,6 +7227,10 @@ msgstr "<<<<<<< HEAD"
msgid "We couldn't load this theme. Please make sure the file is a valid JSON theme file."
msgstr ""
+#: src/strings.ts:2693
+msgid "We couldn't load this theme. The file appears to be incomplete or missing required theme properties."
+msgstr ""
+
#: src/strings.ts:1390
msgid "We have sent you an email confirmation link. Please check your email inbox. If you cannot find the email, check your spam folder."
msgstr ""
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 2f8eb2d92..c629e2d09 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2697,5 +2697,7 @@ Continue without attachments?`,
maximumReminderDate: (maxDate: string) =>
t`Maximum reminder date is ${maxDate}`,
invalidThemeFileFormat: () =>
- t`We couldn't load this theme. Please make sure the file is a valid JSON theme file.`
+ t`We couldn't load this theme. Please make sure the file is a valid JSON theme file.`,
+ themeMissingRequiredFields: () =>
+ t`We couldn't load this theme. The file appears to be incomplete or missing required theme properties.`
};