diff --git a/www/i18n/en.json b/www/i18n/en.json index afd4e2600..ec432d89e 100644 --- a/www/i18n/en.json +++ b/www/i18n/en.json @@ -404,7 +404,8 @@ "all-green-status": "Make sure that all status checks are green", "dont-force-kill": "Do not force kill the app", "background-restrictions": "On Samsung and Huwaei phones, make sure that background restrictions are turned off", - "close": "Close" + "close": "Close", + "proceeding-with-token": "Proceeding with OPcode: {{token}}" }, "config": { "unable-read-saved-config": "Unable to read saved config", diff --git a/www/js/components/AlertBar.tsx b/www/js/components/AlertBar.tsx index 8b1b39fcf..6302bd795 100644 --- a/www/js/components/AlertBar.tsx +++ b/www/js/components/AlertBar.tsx @@ -10,6 +10,7 @@ type AlertMessage = { msgKey?: ParseKeys<'translation'>; text?: string; duration?: number; + style?: object; }; // public static AlertManager that can add messages from a global context @@ -45,6 +46,7 @@ const AlertBar = () => { visible={true} onDismiss={onDismissSnackBar} duration={messages[0].duration} + style={messages[0].style} action={{ label: t('join.close'), onPress: onDismissSnackBar, diff --git a/www/js/config/opcode.ts b/www/js/config/opcode.ts index 63eb02c16..a5483d5c2 100644 --- a/www/js/config/opcode.ts +++ b/www/js/config/opcode.ts @@ -143,11 +143,23 @@ function getTokenFromUrl(url: string) { } export async function joinWithTokenOrUrl(tokenOrUrl: string) { - const token = tokenOrUrl.includes('://') ? getTokenFromUrl(tokenOrUrl) : tokenOrUrl; - AlertManager.addMessage({ text: i18next.t('join.proceeding-with-token', { token }) }); try { - return await initByUser({ token }); + const token = tokenOrUrl.includes('://') ? getTokenFromUrl(tokenOrUrl) : tokenOrUrl; + try { + const result = await initByUser({ token }); + if (result) { + AlertManager.addMessage({ + text: i18next.t('join.proceeding-with-token', { token }), + style: { wordBreak: 'break-all' }, + }); + } + return result; + } catch (err) { + displayError(err, 'Error logging in with token: ' + token); + return false; + } } catch (err) { - displayError(err, 'Error logging in with token'); + displayError(err, 'Error parsing token or URL: ' + tokenOrUrl); + return false; } }