From 876aff9c6921152d768132e80493b417c4a513b1 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 22 Oct 2023 20:47:14 +0200 Subject: [PATCH] Fixed backend UI state retrievals --- sbapp/main.py | 4 +--- sbapp/sideband/core.py | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/sbapp/main.py b/sbapp/main.py index 5f27c6e..247a658 100644 --- a/sbapp/main.py +++ b/sbapp/main.py @@ -1,4 +1,4 @@ -__debug_build__ = False +__debug_build__ = True __disable_shaders__ = False __version__ = "0.6.3" __variant__ = "beta" @@ -217,8 +217,6 @@ class SidebandApp(MDApp): self.open_conversations() if not self.root.ids.screen_manager.has_screen("messages_screen"): - # TODO: Remove - RNS.log("Adding messages screen", RNS.LOG_WARNING) self.messages_screen = Builder.load_string(messages_screen_kv) self.messages_screen.app = self self.root.ids.screen_manager.add_widget(self.messages_screen) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 17d802a..88b9745 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -794,15 +794,18 @@ class SidebandCore(): return False def gui_foreground(self): - return self._db_getstate("app.foreground") + return self.getstate("app.foreground") def gui_display(self): - return self._db_getstate("app.displaying") + return self.getstate("app.displaying") def gui_conversation(self): - return self._db_getstate("app.active_conversation") + return self.getstate("app.active_conversation") def setstate(self, prop, val): + # TODO: remove + us = time.time() + if not RNS.vendor.platformutils.is_android(): self.getstate_cache[prop] = val self._db_setstate(prop, val) @@ -816,12 +819,22 @@ class SidebandCore(): self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key) self.rpc_connection.send({"setstate": (prop, val)}) response = self.rpc_connection.recv() + + # TODO: Remove + # if response: + # RNS.log("RPC setstate SUCCESS for "+str(prop)+"="+str(val)+" in "+RNS.prettytime(time.time()-us), RNS.LOG_WARNING) + # else: + # RNS.log("RPC setstate FAIL for "+str(prop)+"="+str(val)+" in "+RNS.prettytime(time.time()-us), RNS.LOG_WARNING) + return response except Exception as e: RNS.log("Error while setting state over RPC: "+str(e), RNS.LOG_ERROR) return False def getstate(self, prop, allow_cache=False): + # TODO: remove + # us = time.time() + if not RNS.vendor.platformutils.is_android(): return self._db_getstate(prop) else: @@ -836,6 +849,8 @@ class SidebandCore(): self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key) self.rpc_connection.send({"getstate": prop}) response = self.rpc_connection.recv() + # TODO: Remove + # RNS.log("RPC getstate result for "+str(prop)+"="+str(response)+" in "+RNS.prettytime(time.time()-us), RNS.LOG_WARNING) return response except Exception as e: