Skip to content

Commit

Permalink
Fixes for webchat UI.
Browse files Browse the repository at this point in the history
Fixed a few issues with webchat UI.  When sending a message,
make sure the recipient tab is selected after sending.
Also, don't reset the path selection after sending a message.
  • Loading branch information
hemna committed Nov 18, 2024
1 parent 257fa0d commit f0b9956
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
18 changes: 11 additions & 7 deletions aprsd/client/aprsis.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ def setup_connection(self):
return aprs_client

def consumer(self, callback, blocking=False, immortal=False, raw=False):
try:
self._client.consumer(
callback, blocking=blocking,
immortal=immortal, raw=raw,
)
except Exception as e:
LOG.error(f"Exception in consumer: {e}")
if self._client:
try:
self._client.consumer(
callback, blocking=blocking,
immortal=immortal, raw=raw,
)
except Exception as e:
LOG.error(e)
LOG.info(e.__cause__)
else:
LOG.warning("client is None, might be resetting.")
15 changes: 11 additions & 4 deletions aprsd/web/chat/static/js/send-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function init_chat() {

$("#sendform").submit(function(event) {
event.preventDefault();
to_call = $('#to_call').val();
to_call = $('#to_call').val().toUpperCase();
message = $('#message').val();
path = $('#pkt_path option:selected').val();
if (to_call == "") {
Expand All @@ -116,6 +116,8 @@ function init_chat() {
//console.log(msg);
socket.emit("send", msg);
$('#message').val('');
callsign_select(to_call);
activate_callsign_tab(to_call);
}
});

Expand Down Expand Up @@ -418,7 +420,7 @@ function append_message(callsign, msg, msg_html) {

// Find the right div to place the html
new_callsign = add_callsign(callsign, msg);
update_callsign_path(callsign, msg);
//update_callsign_path(callsign, msg);
append_message_html(callsign, msg_html, new_callsign);
len = Object.keys(callsign_list).length;
if (new_callsign && len == 1) {
Expand Down Expand Up @@ -565,16 +567,21 @@ function ack_msg(msg) {
scroll_main_content();
}

function activate_callsign_tab(callsign) {
tab_content = tab_string(callsign, id=true);
$(tab_content).click();
}

function callsign_select(callsign) {
var tocall = $("#to_call");
tocall.val(callsign);
tocall.val(callsign.toUpperCase());
scroll_main_content(callsign);
selected_tab_callsign = callsign;
tab_notify_id = tab_notification_id(callsign, true);
$(tab_notify_id).addClass('visually-hidden');
$(tab_notify_id).text(0);
// Now update the path
$('#pkt_path').val(callsign_list[callsign]);
// $('#pkt_path').val(callsign_list[callsign]);
}

function call_callsign_location(callsign) {
Expand Down

0 comments on commit f0b9956

Please sign in to comment.