From 68ff77e172ddb5303f0cf4d23b03bbd7ca187695 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Wed, 13 Nov 2024 18:20:14 -0500 Subject: [PATCH] ssb: Hook up connect error messages more thoroughly. --- apps/ssb.json | 2 +- apps/ssb/tf-tab-connections.js | 103 ++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 36 deletions(-) diff --git a/apps/ssb.json b/apps/ssb.json index 1ce4263e..315c1abe 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🐌", - "previous": "&CKsS2aS8+7u9S5jDCiqBLA6xr7xLdMHclMKHjzwxcnM=.sha256" + "previous": "&olI6SRBA/dThYusGLGhZ9T2nFKyGB9r+/kb7bJxa4gg=.sha256" } diff --git a/apps/ssb/tf-tab-connections.js b/apps/ssb/tf-tab-connections.js index 1cc34e51..d7baace8 100644 --- a/apps/ssb/tf-tab-connections.js +++ b/apps/ssb/tf-tab-connections.js @@ -12,7 +12,9 @@ class TfTabConnectionsElement extends LitElement { stored_connections: {type: Array}, users: {type: Object}, server_identity: {type: String}, - connect_error: {type: String}, + connect_attempt: {type: Object}, + connect_message: {type: String}, + connect_success: {type: Boolean}, }; } @@ -89,20 +91,36 @@ class TfTabConnectionsElement extends LitElement { `; } + render_message(connection) { + return html`
this.connect_attempt = undefined} + > +

${this.connect_message}

+
`; + } + render_broadcast(connection) { + let self = this; return html` -
  • - -
    - ${TfTabConnectionsElement.k_broadcast_emojis[connection.origin]} - - ${this.render_connection_summary(connection)} +
  • +
    + +
    + ${TfTabConnectionsElement.k_broadcast_emojis[connection.origin]} + + ${this.render_connection_summary(connection)} +
    + ${this.render_message(connection)}
  • `; } @@ -166,11 +184,23 @@ class TfTabConnectionsElement extends LitElement { connect(address) { let self = this; - tfrpc.rpc.connect(address).then(function() { - self.connect_error = 'connected!'; - }).catch(function(error) { - self.connect_error = error; - }); + self.connect_attempt = address; + self.connect_message = undefined; + self.connect_success = false; + tfrpc.rpc + .connect(address) + .then(function () { + if (self.connect_attempt == address) { + self.connect_message = 'Connected.'; + self.connect_success = true; + } + }) + .catch(function (error) { + if (self.connect_attempt == address) { + self.connect_message = 'Error: ' + error; + self.connect_success = false; + } + }); } render() { @@ -185,14 +215,14 @@ class TfTabConnectionsElement extends LitElement {

    New Connection

    + ${this.render_message(this.renderRoot.getElementById('code')?.value)} -
    ${this.connect_error}

    Broadcasts