Settings reload for split ui/service

This commit is contained in:
Mark Qvist 2022-10-02 12:45:06 +02:00
parent a74e0f9cf7
commit 7368cf766e
4 changed files with 27 additions and 7 deletions

View File

@ -162,6 +162,10 @@ class SidebandService():
if self.notification_service != None: if self.notification_service != None:
self.notification_service.cancelAll() self.notification_service.cancelAll()
if self.sideband.getstate("wants.settings_reload"):
self.sideband.setstate("wants.settings_reload", False)
self.sideband.reload_configuration()
time.sleep(sleep_time) time.sleep(sleep_time)
self.release_locks() self.release_locks()

View File

@ -191,10 +191,10 @@ class SidebandCore():
self.save_configuration() self.save_configuration()
def __load_config(self): def __load_config(self):
RNS.log("Loading Sideband identity...") RNS.log("Loading Sideband identity...", RNS.LOG_DEBUG)
self.identity = RNS.Identity.from_file(self.identity_path) self.identity = RNS.Identity.from_file(self.identity_path)
RNS.log("Loading Sideband configuration... "+str(self.config_path)) RNS.log("Loading Sideband configuration... "+str(self.config_path), RNS.LOG_DEBUG)
config_file = open(self.config_path, "rb") config_file = open(self.config_path, "rb")
self.config = msgpack.unpackb(config_file.read()) self.config = msgpack.unpackb(config_file.read())
config_file.close() config_file.close()
@ -206,15 +206,27 @@ class SidebandCore():
self._db_initpersistent() self._db_initpersistent()
def __reload_config(self):
RNS.log("Reloading Sideband configuration... "+str(self.config_path), RNS.LOG_DEBUG)
config_file = open(self.config_path, "rb")
self.config = msgpack.unpackb(config_file.read())
config_file.close()
self.update_active_lxmf_propagation_node()
def __save_config(self): def __save_config(self):
RNS.log("Saving Sideband configuration...") RNS.log("Saving Sideband configuration...", RNS.LOG_DEBUG)
config_file = open(self.config_path, "wb") config_file = open(self.config_path, "wb")
config_file.write(msgpack.packb(self.config)) config_file.write(msgpack.packb(self.config))
config_file.close() config_file.close()
if self.is_client:
self.setstate("wants.settings_reload", True)
def reload_configuration(self):
self.__reload_config()
def save_configuration(self): def save_configuration(self):
RNS.log("Saving configuration")
self.__save_config() self.__save_config()
def set_active_propagation_node(self, dest): def set_active_propagation_node(self, dest):
@ -1009,6 +1021,9 @@ class SidebandCore():
self.rns_dir = RNS.Reticulum.configdir self.rns_dir = RNS.Reticulum.configdir
self.update_active_lxmf_propagation_node()
def update_active_lxmf_propagation_node(self):
if self.config["lxmf_propagation_node"] != None and self.config["lxmf_propagation_node"] != "": if self.config["lxmf_propagation_node"] != None and self.config["lxmf_propagation_node"] != "":
self.set_active_propagation_node(self.config["lxmf_propagation_node"]) self.set_active_propagation_node(self.config["lxmf_propagation_node"])
else: else:

View File

@ -74,10 +74,11 @@ class Conversations():
else: else:
trust_icon = "account-question" trust_icon = "account-question"
iconl = IconLeftWidget(icon=trust_icon) iconl = IconLeftWidget(icon=trust_icon, on_release=self.app.conversation_action)
item = OneLineAvatarIconListItem(text=self.app.sideband.peer_display_name(context_dest), on_release=self.app.conversation_action) item = OneLineAvatarIconListItem(text=self.app.sideband.peer_display_name(context_dest), on_release=self.app.conversation_action)
item.add_widget(iconl) item.add_widget(iconl)
item.sb_uid = context_dest item.sb_uid = context_dest
iconl.sb_uid = context_dest
def gen_edit(dest, item): def gen_edit(dest, item):
def x(): def x():

View File

@ -677,7 +677,7 @@ MDNavigationLayout:
height: dp(48) height: dp(48)
MDLabel: MDLabel:
text: "Deliver via LXMF Propagation Node by default" text: "Send via Propagation Node by default"
font_style: "H6" font_style: "H6"
MDSwitch: MDSwitch: