From cde54442d20cc72a8b286ada3f4b32320ba63442 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Thu, 21 Sep 2023 09:07:49 +0200 Subject: [PATCH] webmail: in status line about (re|dis)connecting, make error message more readable with space after line, so a next line doesn't get concatenated. and with capital. --- webmail/webmail.js | 7 ++++--- webmail/webmail.ts | 8 +++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/webmail/webmail.js b/webmail/webmail.js index 76a09f6..aaabe4b 100644 --- a/webmail/webmail.js +++ b/webmail/webmail.js @@ -5520,6 +5520,7 @@ const init = async () => { } })); }; + const capitalizeFirst = (s) => s.charAt(0).toUpperCase() + s.slice(1); const connect = async (isreconnect) => { connectionElem.classList.toggle('loading', true); dom._kids(connectionElem); @@ -5534,7 +5535,7 @@ const init = async () => { catch (err) { connecting = false; noreconnect = true; - dom._kids(statusElem, (err.message || 'error fetching connection token') + ', not automatically retrying'); + dom._kids(statusElem, (capitalizeFirst(err.message || 'Error fetching connection token')) + ', not automatically retrying. '); showNotConnected(); return; } @@ -5582,7 +5583,7 @@ const init = async () => { } catch (err) { } eventSource = new window.EventSource('events?token=' + encodeURIComponent(token) + '&request=' + encodeURIComponent(JSON.stringify(request)) + slow); - let eventID = window.setTimeout(() => dom._kids(statusElem, 'Connecting...'), 1000); + let eventID = window.setTimeout(() => dom._kids(statusElem, 'Connecting... '), 1000); eventSource.addEventListener('open', (e) => { log('eventsource open', { e }); if (eventID) { @@ -5611,7 +5612,7 @@ const init = async () => { document.title = ['(not connected)', loginAddress ? (loginAddress.User + '@' + (loginAddress.Domain.Unicode || loginAddress.Domain.ASCII)) : '', 'Mox Webmail'].filter(s => s).join(' - '); dom._kids(connectionElem); if (noreconnect) { - dom._kids(statusElem, errmsg + ', not automatically retrying'); + dom._kids(statusElem, capitalizeFirst(errmsg) + ', not automatically retrying. '); showNotConnected(); listloadingElem.remove(); listendElem.remove(); diff --git a/webmail/webmail.ts b/webmail/webmail.ts index 5b6c967..97e1035 100644 --- a/webmail/webmail.ts +++ b/webmail/webmail.ts @@ -5907,6 +5907,8 @@ const init = async () => { ) } + const capitalizeFirst = (s: string) => s.charAt(0).toUpperCase() + s.slice(1) + const connect = async (isreconnect: boolean) => { connectionElem.classList.toggle('loading', true) dom._kids(connectionElem) @@ -5922,7 +5924,7 @@ const init = async () => { } catch (err) { connecting = false noreconnect = true - dom._kids(statusElem, ((err as any).message || 'error fetching connection token')+', not automatically retrying') + dom._kids(statusElem, (capitalizeFirst((err as any).message || 'Error fetching connection token'))+', not automatically retrying. ') showNotConnected() return } @@ -5975,7 +5977,7 @@ const init = async () => { } catch (err) {} eventSource = new window.EventSource('events?token=' + encodeURIComponent(token)+'&request='+encodeURIComponent(JSON.stringify(request))+slow) - let eventID = window.setTimeout(() => dom._kids(statusElem, 'Connecting...'), 1000) + let eventID = window.setTimeout(() => dom._kids(statusElem, 'Connecting... '), 1000) eventSource.addEventListener('open', (e: Event) => { log('eventsource open', {e}) if (eventID) { @@ -6005,7 +6007,7 @@ const init = async () => { document.title = ['(not connected)', loginAddress ? (loginAddress.User+'@'+(loginAddress.Domain.Unicode || loginAddress.Domain.ASCII)) : '', 'Mox Webmail'].filter(s => s).join(' - ') dom._kids(connectionElem) if (noreconnect) { - dom._kids(statusElem, errmsg+', not automatically retrying') + dom._kids(statusElem, capitalizeFirst(errmsg)+', not automatically retrying. ') showNotConnected() listloadingElem.remove() listendElem.remove()