ui: Inject ids for messages.

This commit is contained in:
tecnovert 2022-10-14 14:22:11 +02:00
parent 842027f114
commit 3c84f0230e
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93

View file

@ -124,6 +124,22 @@ class HttpHandler(BaseHTTPRequestHandler):
if swap_client._show_notifications: if swap_client._show_notifications:
args_dict['notifications'] = swap_client.getNotifications() args_dict['notifications'] = swap_client.getNotifications()
if 'messages' in args_dict:
messages_with_ids = []
for msg in args_dict['messages']:
messages_with_ids.append((self.server.msg_id_counter, msg))
self.server.msg_id_counter += 1
args_dict['messages'] = messages_with_ids
if 'err_messages' in args_dict:
err_messages_with_ids = []
for msg in args_dict['err_messages']:
err_messages_with_ids.append((self.server.msg_id_counter, msg))
self.server.msg_id_counter += 1
args_dict['err_messages'] = err_messages_with_ids
if self.server.msg_id_counter >= 0x7FFFFFFF:
self.server.msg_id_counter = 0
self.putHeaders(200, 'text/html') self.putHeaders(200, 'text/html')
return bytes(template.render( return bytes(template.render(
title=self.server.title, title=self.server.title,
@ -698,6 +714,7 @@ class HttpThread(threading.Thread, HTTPServer):
self.last_form_id = dict() self.last_form_id = dict()
self.session_tokens = dict() self.session_tokens = dict()
self.env = env self.env = env
self.msg_id_counter = 0
self.timeout = 60 self.timeout = 60
HTTPServer.__init__(self, (self.host_name, self.port_no), HttpHandler) HTTPServer.__init__(self, (self.host_name, self.port_no), HttpHandler)