Skip to content
Snippets Groups Projects
Commit 487e1cd2 authored by Bahtiar Gadimov's avatar Bahtiar Gadimov
Browse files

Replace is_omemo_enabled with an init var

parent 745f56d1
No related branches found
No related tags found
No related merge requests found
......@@ -214,7 +214,9 @@ class OmemoPlugin(GajimPlugin):
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. """
......@@ -420,12 +422,6 @@ class OmemoPlugin(GajimPlugin):
except:
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 """
......
......@@ -92,7 +92,7 @@ class Ui(object):
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 @@ class Ui(object):
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment