mirror of
https://github.com/pdxlocations/contact.git
synced 2026-08-04 16:03:37 +02:00
Merge pull request #31 from rfschmid/limit-more-drawing
This commit is contained in:
@@ -22,8 +22,10 @@ def on_receive(packet, interface):
|
||||
|
||||
# Assume any incoming packet could update the last seen time for a node, so we
|
||||
# may need to reorder the list. This could probably be limited to specific packets.
|
||||
globals.node_list = get_node_list()
|
||||
draw_node_list()
|
||||
new_node_list = get_node_list()
|
||||
if(new_node_list != globals.node_list):
|
||||
globals.node_list = new_node_list
|
||||
draw_node_list()
|
||||
|
||||
if packet['decoded']['portnum'] == 'NODEINFO_APP':
|
||||
if "user" in packet['decoded'] and "longName" in packet['decoded']["user"]:
|
||||
@@ -32,6 +34,10 @@ def on_receive(packet, interface):
|
||||
elif packet['decoded']['portnum'] == 'TEXT_MESSAGE_APP':
|
||||
message_bytes = packet['decoded']['payload']
|
||||
message_string = message_bytes.decode('utf-8')
|
||||
|
||||
refresh_channels = False
|
||||
refresh_messages = False
|
||||
|
||||
if packet.get('channel'):
|
||||
channel_number = packet['channel']
|
||||
else:
|
||||
@@ -42,12 +48,15 @@ def on_receive(packet, interface):
|
||||
else:
|
||||
globals.channel_list.append(packet['from'])
|
||||
globals.all_messages[packet['from']] = []
|
||||
draw_channel_list()
|
||||
refresh_channels = True
|
||||
|
||||
channel_number = globals.channel_list.index(packet['from'])
|
||||
|
||||
if globals.channel_list[channel_number] != globals.channel_list[globals.selected_channel]:
|
||||
add_notification(channel_number)
|
||||
refresh_channels = True
|
||||
else:
|
||||
refresh_messages = True
|
||||
|
||||
# Add received message to the messages list
|
||||
message_from_id = packet['from']
|
||||
@@ -58,8 +67,11 @@ def on_receive(packet, interface):
|
||||
|
||||
globals.all_messages[globals.channel_list[channel_number]].append((f"{globals.message_prefix} {message_from_string} ", message_string))
|
||||
|
||||
draw_channel_list()
|
||||
draw_messages_window()
|
||||
if(refresh_channels):
|
||||
draw_channel_list()
|
||||
if(refresh_messages):
|
||||
draw_messages_window()
|
||||
|
||||
save_message_to_db(globals.channel_list[channel_number], message_from_id, message_string)
|
||||
|
||||
except KeyError as e:
|
||||
|
||||
@@ -35,12 +35,17 @@ def onAckNak(packet):
|
||||
|
||||
update_ack_nak(acknak['channel'], acknak['timestamp'], message, ack_type)
|
||||
|
||||
draw_messages_window()
|
||||
channel_number = globals.channel_list.index(acknak['channel'])
|
||||
if globals.channel_list[channel_number] == globals.channel_list[globals.selected_channel]:
|
||||
draw_messages_window()
|
||||
|
||||
def on_response_traceroute(packet):
|
||||
"""on response for trace route"""
|
||||
from ui.curses_ui import draw_channel_list, draw_messages_window, add_notification
|
||||
|
||||
refresh_channels = False
|
||||
refresh_messages = False
|
||||
|
||||
UNK_SNR = -128 # Value representing unknown SNR
|
||||
|
||||
route_discovery = mesh_pb2.RouteDiscovery()
|
||||
@@ -85,11 +90,15 @@ def on_response_traceroute(packet):
|
||||
|
||||
if(packet['from'] not in globals.channel_list):
|
||||
globals.channel_list.append(packet['from'])
|
||||
refresh_channels = True
|
||||
|
||||
channel_number = globals.channel_list.index(packet['from'])
|
||||
|
||||
if globals.channel_list[channel_number] != globals.channel_list[globals.selected_channel]:
|
||||
if globals.channel_list[channel_number] == globals.channel_list[globals.selected_channel]:
|
||||
refresh_messages = True
|
||||
else:
|
||||
add_notification(channel_number)
|
||||
refresh_channels = True
|
||||
|
||||
message_from_string = get_name_from_number(packet['from'], type='short') + ":\n"
|
||||
|
||||
@@ -97,8 +106,10 @@ def on_response_traceroute(packet):
|
||||
globals.all_messages[globals.channel_list[channel_number]] = []
|
||||
globals.all_messages[globals.channel_list[channel_number]].append((f"{globals.message_prefix} {message_from_string}", msg_str))
|
||||
|
||||
draw_channel_list()
|
||||
draw_messages_window()
|
||||
if(refresh_channels):
|
||||
draw_channel_list()
|
||||
if(refresh_messages):
|
||||
draw_messages_window()
|
||||
save_message_to_db(globals.channel_list[channel_number], packet['from'], msg_str)
|
||||
|
||||
def send_message(message, destination=BROADCAST_NUM, channel=0):
|
||||
|
||||
Reference in New Issue
Block a user