Commit a7826b7b authored by Maxime Buquet's avatar Maxime Buquet

ChatTab: Change meaning

`` is now its own property. It only mirrors `ChatTab.jid`
when it is None for compat reasons.

If code tries to set `` and it is a valid JID, `ChatTab.jid`
is set instead for compat reasons and `` stays with its
previous value.

To have `` mirror `ChatTab.jid` again, set it to None.
Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <>
parent 0a478113
...@@ -470,7 +470,7 @@ class ChatTab(Tab): ...@@ -470,7 +470,7 @@ class ChatTab(Tab):
assert jid.domain assert jid.domain
self._jid = jid self._jid = jid
self._name = jid.full self._name = jid.full # type: Optional[str]
self.text_win = None self.text_win = None
self.directed_presence = None self.directed_presence = None
self._text_buffer = TextBuffer() self._text_buffer = TextBuffer()
...@@ -517,24 +517,23 @@ class ChatTab(Tab): ...@@ -517,24 +517,23 @@ class ChatTab(Tab):
@property @property
def name(self) -> str: def name(self) -> str:
if self._jid is not None: if self._name is not None:
return self._jid.full return self._name
return self._name return self._jid.full
@name.setter @name.setter
def name(self, value: Union[JID, str]) -> None: def name(self, value: Union[JID, str]) -> None:
if isinstance(value, JID): if isinstance(value, JID):
self._jid = value self.jid = value
elif isinstance(value, str): elif isinstance(value, str):
try: try:
value = JID(value) value = JID(value)
if value.domain: if value.domain:
self._jid = value self._jid = value
self._name = value.full
except InvalidJID: except InvalidJID:
self._name = value self._name = value
else: else:
raise TypeError("Name must be of type JID or str.") raise TypeError("Name %r must be of type JID or str." % value)
@property @property
def jid(self) -> JID: def jid(self) -> JID:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment