Fixed backend UI state retrievals

This commit is contained in:
Mark Qvist 2023-10-22 20:47:14 +02:00
parent a091389fa1
commit 876aff9c69
2 changed files with 19 additions and 6 deletions

View File

@ -1,4 +1,4 @@
__debug_build__ = False __debug_build__ = True
__disable_shaders__ = False __disable_shaders__ = False
__version__ = "0.6.3" __version__ = "0.6.3"
__variant__ = "beta" __variant__ = "beta"
@ -217,8 +217,6 @@ class SidebandApp(MDApp):
self.open_conversations() self.open_conversations()
if not self.root.ids.screen_manager.has_screen("messages_screen"): 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 = Builder.load_string(messages_screen_kv)
self.messages_screen.app = self self.messages_screen.app = self
self.root.ids.screen_manager.add_widget(self.messages_screen) self.root.ids.screen_manager.add_widget(self.messages_screen)

View File

@ -794,15 +794,18 @@ class SidebandCore():
return False return False
def gui_foreground(self): def gui_foreground(self):
return self._db_getstate("app.foreground") return self.getstate("app.foreground")
def gui_display(self): def gui_display(self):
return self._db_getstate("app.displaying") return self.getstate("app.displaying")
def gui_conversation(self): def gui_conversation(self):
return self._db_getstate("app.active_conversation") return self.getstate("app.active_conversation")
def setstate(self, prop, val): def setstate(self, prop, val):
# TODO: remove
us = time.time()
if not RNS.vendor.platformutils.is_android(): if not RNS.vendor.platformutils.is_android():
self.getstate_cache[prop] = val self.getstate_cache[prop] = val
self._db_setstate(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 = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
self.rpc_connection.send({"setstate": (prop, val)}) self.rpc_connection.send({"setstate": (prop, val)})
response = self.rpc_connection.recv() 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 return response
except Exception as e: except Exception as e:
RNS.log("Error while setting state over RPC: "+str(e), RNS.LOG_ERROR) RNS.log("Error while setting state over RPC: "+str(e), RNS.LOG_ERROR)
return False return False
def getstate(self, prop, allow_cache=False): def getstate(self, prop, allow_cache=False):
# TODO: remove
# us = time.time()
if not RNS.vendor.platformutils.is_android(): if not RNS.vendor.platformutils.is_android():
return self._db_getstate(prop) return self._db_getstate(prop)
else: else:
@ -836,6 +849,8 @@ class SidebandCore():
self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key) self.rpc_connection = multiprocessing.connection.Client(self.rpc_addr, authkey=self.rpc_key)
self.rpc_connection.send({"getstate": prop}) self.rpc_connection.send({"getstate": prop})
response = self.rpc_connection.recv() 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 return response
except Exception as e: except Exception as e: