Commit a7826b7b authored by Maxime Buquet's avatar Maxime Buquet

ChatTab: Change ChatTab.name meaning

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

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

To have `ChatTab.name` mirror `ChatTab.jid` again, set it to None.
Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent 0a478113
......@@ -470,7 +470,7 @@ class ChatTab(Tab):
assert jid.domain
self._jid = jid
self._name = jid.full
self._name = jid.full # type: Optional[str]
self.text_win = None
self.directed_presence = None
self._text_buffer = TextBuffer()
......@@ -517,24 +517,23 @@ class ChatTab(Tab):
@property
def name(self) -> str:
if self._jid is not None:
return self._jid.full
return self._name
if self._name is not None:
return self._name
return self._jid.full
@name.setter
def name(self, value: Union[JID, str]) -> None:
if isinstance(value, JID):
self._jid = value
self.jid = value
elif isinstance(value, str):
try:
value = JID(value)
if value.domain:
self._jid = value
self._name = value.full
except InvalidJID:
self._name = value
else:
raise TypeError("Name must be of type JID or str.")
raise TypeError("Name %r must be of type JID or str." % value)
@property
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