changeset 99f455f0dd0f in /home/hg/repos/gajim-plugins

author: Bahtiar `kalkin-` Gadimov <[email protected]>
branches: 
details:gajim-plugins?cmd=changeset;node=99f455f0dd0f
description: Replace is_omemo_enabled with an init var

diffstat:

 omemo/__init__.py |  10 +++-------
 omemo/ui.py       |   4 ++--
 2 files changed, 5 insertions(+), 9 deletions(-)

diffs (48 lines):

diff -r d78f799c5652 -r 99f455f0dd0f omemo/__init__.py
--- a/omemo/__init__.py Thu Jan 07 21:08:16 2016 +0100
+++ b/omemo/__init__.py Thu Jan 07 21:36:26 2016 +0100
@@ -214,7 +214,9 @@
         jid = chat_control.contact.jid
         if account not in self.ui_list:
             self.ui_list[account] = {}
-        self.ui_list[account][jid] = Ui(self, chat_control)
+        state = self.get_omemo_state(account)
+        omemo_enabled = jid in state.omemo_enabled
+        self.ui_list[account][jid] = Ui(self, chat_control, omemo_enabled)
 
     def are_keys_missing(self, contact):
         """ Used by the ui to set the state of the PreKeyButton. """
@@ -421,12 +423,6 @@
             return True
 
     @log_calls('OmemoPlugin')
-    def is_omemo_enabled(self, contact):
-        account = contact.account.name
-        state = self.get_omemo_state(account)
-        return contact.jid in state.omemo_enabled
-
-    @log_calls('OmemoPlugin')
     def omemo_enable_for(self, contact):
         """ Used by the ui to enable omemo for a specified contact """
         account = contact.account.name
diff -r d78f799c5652 -r 99f455f0dd0f omemo/ui.py
--- a/omemo/ui.py       Thu Jan 07 21:08:16 2016 +0100
+++ b/omemo/ui.py       Thu Jan 07 21:36:26 2016 +0100
@@ -92,7 +92,7 @@
 
     last_msg_plain = True
 
-    def __init__(self, plugin, chat_control):
+    def __init__(self, plugin, chat_control, enabled):
         contact = chat_control.contact
         self.prekey_button = PreKeyButton(plugin, contact)
         self.checkbox = Checkbox(plugin, chat_control)
@@ -101,7 +101,7 @@
         available = plugin.has_omemo(contact)
         self.toggle_omemo(available)
 
-        self.checkbox.set_active(plugin.is_omemo_enabled(contact))
+        self.checkbox.set_active(enabled)
         self.chat_control = chat_control
 
         _add_widget(self.prekey_button, chat_control)
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to