diff --git a/app/main.py b/app/main.py index cf83d50..5570900 100644 --- a/app/main.py +++ b/app/main.py @@ -560,7 +560,14 @@ PAGE_HTML = """

Matrix chat

-

You're invited to the co-op's Matrix space at your co-op account (@you:inference.coop). Prefer to use an existing account on another server instead? Add it below (one account).

+

You're invited to the co-op's Matrix space. Your registered Matrix ID:

+
+
Registered Matrix ID
+ checking… +
+ +
+
@@ -643,17 +650,37 @@ async function loadMxid() { const r = await fetch('/api/matrix-mxid'); if (r.status === 401) return; const d = await r.json(); - if (d.error) return; - if (d.local_mxid) $('local-mxid').textContent = d.local_mxid; - if (d.matrix_mxid) { - $('mxid-input').value = d.matrix_mxid; - $('mxid-status').textContent = 'Using ' + d.matrix_mxid + ' for Matrix invites.'; + if (d.error) { + $('mxid-registered-value').textContent = 'unavailable'; + $('mxid-status').textContent = 'Could not load your Matrix registration: ' + d.error; + return; } - } catch (e) { /* non-critical */ } + const custom = (d.matrix_mxid || '').trim(); + const local = d.local_mxid || ''; + if (custom) { + $('mxid-registered-value').textContent = custom; + $('mxid-registered-note').textContent = 'External account — Matrix invites go here; your co-op account will not receive them.'; + $('mxid-input').value = custom; + $('mxid-clear').style.display = ''; + $('mxid-custom-hint').style.display = ''; + } else if (local) { + $('mxid-registered-value').textContent = local; + $('mxid-registered-note').textContent = 'Your co-op account — invites go here.'; + } else { + $('mxid-registered-value').textContent = 'not set yet — invites go to your co-op account once it exists'; + } + } catch (e) { + $('mxid-registered-value').textContent = 'unavailable'; + $('mxid-status').textContent = 'Could not load your Matrix registration: ' + e.message; + } } -async function saveMxid() { - const mxid = $('mxid-input').value.trim(); +async function clearMxid() { + await saveMxid(''); +} + +async function saveMxid(explicit) { + const mxid = (explicit !== undefined ? explicit : $('mxid-input').value).trim(); const btn = $('mxid-btn'); btn.disabled = true; $('mxid-status').textContent = ''; @@ -672,8 +699,12 @@ async function saveMxid() { $('mxid-status').className = 'hint ok'; } else { $('mxid-status').textContent = 'Cleared — your co-op account will be used for Matrix.'; + $('mxid-status').className = 'hint ok'; $('mxid-input').value = ''; + $('mxid-clear').style.display = 'none'; } + btn.disabled = false; + await loadMxid(); } catch (e) { $('mxid-status').textContent = 'Could not save: ' + e.message; } btn.disabled = false; }