A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix(mobile): better error message in the login page
Mohamed Basseme88a606cc884
diff --git a/apps/mobile/app/signin.tsx b/apps/mobile/app/signin.tsxindex 6bf6817e..25ef400f 100644--- a/apps/mobile/app/signin.tsx+++ b/apps/mobile/app/signin.tsx@@ -22,6 +22,23 @@ enum LoginType {}const DEFAULT_SERVER_ADDRESS = "https://cloud.karakeep.app";+const CONNECTION_ERROR_MESSAGE =+ "Couldn’t connect to this Karakeep server. Check the server address and your internet connection, then try again.";++function getLoginErrorMessage(+ error: { data?: { code?: string } | null; message: string },+ unauthorizedMessage: string,+) {+ if (error.data?.code === "UNAUTHORIZED") {+ return unauthorizedMessage;+ }++ if (error.message.toLowerCase().includes("fetch failed")) {+ return CONNECTION_ERROR_MESSAGE;+ }++ return error.message;+}// The logo artboard is 598x166; derive the width so it never letterboxes.const LOGO_HEIGHT = 52;@@ -67,11 +84,7 @@ export default function Signin() {setSettings({ ...settings, apiKey: resp.key, apiKeyId: resp.id });},onError: (e) => {- if (e.data?.code === "UNAUTHORIZED") {- setError("Wrong username or password");- } else {- setError(`${e.message}`);- }+ setError(getLoginErrorMessage(e, "Wrong username or password"));},}),);@@ -84,11 +97,7 @@ export default function Signin() {setSettings({ ...settings, apiKey: apiKey });},onError: (e) => {- if (e.data?.code === "UNAUTHORIZED") {- setError("Invalid API key");- } else {- setError(`${e.message}`);- }+ setError(getLoginErrorMessage(e, "Invalid API key"));},}),);@@ -121,6 +130,8 @@ export default function Signin() {return;}+ setError(undefined);+if (loginType === LoginType.Password) {const email = emailRef.current;const password = passwordRef.current;