diff --git a/apps/ssb.json b/apps/ssb.json index 79ea4588..24bcb978 100644 --- a/apps/ssb.json +++ b/apps/ssb.json @@ -1,5 +1,5 @@ { "type": "tildefriends-app", "emoji": "🦀", - "previous": "&jbL9Ab+XdvWnZbb50yimceFHR7XFDfBSWv9/XrbZ82I=.sha256" + "previous": "&BHYyqkjBliajHR0fokZPpBjkB0Ds8kkwEIRHWit0kIk=.sha256" } diff --git a/apps/ssb/tf-tab-connections.js b/apps/ssb/tf-tab-connections.js index 3c8e71ff..384f28b5 100644 --- a/apps/ssb/tf-tab-connections.js +++ b/apps/ssb/tf-tab-connections.js @@ -142,12 +142,15 @@ class TfTabConnectionsElement extends LitElement { }, {}) ); return html` - + ${connection.connected ? html` + + ` + : undefined} ${connection.flags.one_shot ? '🔃' : undefined} ${connection.tunnel !== undefined diff --git a/src/ssb.c b/src/ssb.c index 478e3c5f..b4243518 100644 --- a/src/ssb.c +++ b/src/ssb.c @@ -1356,7 +1356,8 @@ bool tf_ssb_connection_is_client(tf_ssb_connection_t* connection) bool tf_ssb_connection_is_connected(tf_ssb_connection_t* connection) { - return connection->state == k_tf_ssb_state_verified || connection->state == k_tf_ssb_state_server_verified; + return (connection->state == k_tf_ssb_state_verified || connection->state == k_tf_ssb_state_server_verified) && + !connection->is_closing; } bool tf_ssb_connection_is_closing(tf_ssb_connection_t* connection) @@ -2795,8 +2796,6 @@ static tf_ssb_connection_t* _tf_ssb_connection_create_internal(tf_ssb_t* ssb, co connection->next = ssb->connections; ssb->connections = connection; ssb->connections_count++; - _tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection); - return connection; } @@ -2847,6 +2846,7 @@ static tf_ssb_connection_t* _tf_ssb_connection_create( } memcpy(connection->serverpub, public_key, sizeof(connection->serverpub)); + _tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection); connection->tcp.data = connection; uv_tcp_init(ssb->loop, &connection->tcp); @@ -2928,6 +2928,7 @@ tf_ssb_connection_t* tf_ssb_connection_tunnel_create(tf_ssb_t* ssb, const char* { tunnel->state = k_tf_ssb_state_server_wait_hello; } + _tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection); return tunnel; } @@ -3058,6 +3059,7 @@ static void _tf_ssb_on_connection(uv_stream_t* stream, int status) } connection->state = k_tf_ssb_state_server_wait_hello; + _tf_ssb_notify_connections_changed(ssb, k_tf_ssb_change_create, connection); _tf_ssb_connection_read_start(connection); } diff --git a/src/ssb.js.c b/src/ssb.js.c index 3ee531c6..160c32de 100644 --- a/src/ssb.js.c +++ b/src/ssb.js.c @@ -1015,6 +1015,7 @@ static JSValue _tf_ssb_connections(JSContext* context, JSValueConst this_val, in int flags = tf_ssb_connection_get_flags(connection); JS_SetPropertyStr(context, flags_object, "one_shot", JS_NewBool(context, (flags & k_tf_ssb_connect_flag_one_shot) != 0)); JS_SetPropertyStr(context, object, "flags", flags_object); + JS_SetPropertyStr(context, object, "connected", JS_NewBool(context, tf_ssb_connection_is_connected(connection))); const char* destroy_reason = tf_ssb_connection_get_destroy_reason(connection); if (destroy_reason) {