Notification logic
This commit is contained in:
parent
93d214ead6
commit
a74e0f9cf7
|
@ -160,6 +160,7 @@ class SidebandApp(MDApp):
|
||||||
def on_resume(self):
|
def on_resume(self):
|
||||||
self.sideband.setstate("app.running", True)
|
self.sideband.setstate("app.running", True)
|
||||||
self.sideband.setstate("app.foreground", True)
|
self.sideband.setstate("app.foreground", True)
|
||||||
|
self.sideband.setstate("wants.clear_notifications", True)
|
||||||
self.app_state = SidebandApp.ACTIVE
|
self.app_state = SidebandApp.ACTIVE
|
||||||
|
|
||||||
def on_stop(self):
|
def on_stop(self):
|
||||||
|
@ -494,6 +495,7 @@ class SidebandApp(MDApp):
|
||||||
self.root.ids.screen_manager.current = "conversations_screen"
|
self.root.ids.screen_manager.current = "conversations_screen"
|
||||||
self.root.ids.messages_scrollview.active_conversation = None
|
self.root.ids.messages_scrollview.active_conversation = None
|
||||||
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
|
||||||
|
self.sideband.setstate("wants.clear_notifications", True)
|
||||||
|
|
||||||
def connectivity_status(self, sender):
|
def connectivity_status(self, sender):
|
||||||
hs = dp(22)
|
hs = dp(22)
|
||||||
|
|
|
@ -157,6 +157,11 @@ class SidebandService():
|
||||||
self.should_run = False
|
self.should_run = False
|
||||||
sleep_time = 0
|
sleep_time = 0
|
||||||
|
|
||||||
|
if self.sideband.getstate("wants.clear_notifications"):
|
||||||
|
self.sideband.setstate("wants.clear_notifications", False)
|
||||||
|
if self.notification_service != None:
|
||||||
|
self.notification_service.cancelAll()
|
||||||
|
|
||||||
time.sleep(sleep_time)
|
time.sleep(sleep_time)
|
||||||
|
|
||||||
self.release_locks()
|
self.release_locks()
|
||||||
|
|
|
@ -1096,9 +1096,6 @@ class SidebandCore():
|
||||||
context_dest = message.source_hash
|
context_dest = message.source_hash
|
||||||
is_trusted = self.is_trusted(context_dest)
|
is_trusted = self.is_trusted(context_dest)
|
||||||
|
|
||||||
if is_trusted:
|
|
||||||
should_notify = True
|
|
||||||
|
|
||||||
if self._db_message(message.hash):
|
if self._db_message(message.hash):
|
||||||
RNS.log("Message exists, setting state to: "+str(message.state), RNS.LOG_DEBUG)
|
RNS.log("Message exists, setting state to: "+str(message.state), RNS.LOG_DEBUG)
|
||||||
self._db_message_set_state(message.hash, message.state)
|
self._db_message_set_state(message.hash, message.state)
|
||||||
|
@ -1106,6 +1103,9 @@ class SidebandCore():
|
||||||
RNS.log("Message does not exist, saving", RNS.LOG_DEBUG)
|
RNS.log("Message does not exist, saving", RNS.LOG_DEBUG)
|
||||||
self._db_save_lxm(message, context_dest)
|
self._db_save_lxm(message, context_dest)
|
||||||
|
|
||||||
|
if is_trusted:
|
||||||
|
should_notify = True
|
||||||
|
|
||||||
if self._db_conversation(context_dest) == None:
|
if self._db_conversation(context_dest) == None:
|
||||||
self._db_create_conversation(context_dest)
|
self._db_create_conversation(context_dest)
|
||||||
self.setstate("app.flags.new_conversations", True)
|
self.setstate("app.flags.new_conversations", True)
|
||||||
|
@ -1121,6 +1121,9 @@ class SidebandCore():
|
||||||
self.unread_conversation(context_dest)
|
self.unread_conversation(context_dest)
|
||||||
self.setstate("app.flags.unread_conversations", True)
|
self.setstate("app.flags.unread_conversations", True)
|
||||||
|
|
||||||
|
if self.gui_display() == "conversations_screen" and self.gui_foreground():
|
||||||
|
should_notify = False
|
||||||
|
|
||||||
if self.is_client:
|
if self.is_client:
|
||||||
should_notify = False
|
should_notify = False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue