summaryrefslogtreecommitdiff
path: root/poezio/tabs
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-04-27 20:37:44 +0100
committerMaxime “pep” Buquet <pep@bouah.net>2019-04-27 20:42:54 +0100
commita7826b7b330ea3f3747b2a92fc48456592e77a5b (patch)
tree7d9c8f6d5a53143ccc67668c0df813a913dabc5a /poezio/tabs
parent0a4781134e620079c6788d47616fc4bfa99e0321 (diff)
downloadpoezio-a7826b7b330ea3f3747b2a92fc48456592e77a5b.tar.gz
poezio-a7826b7b330ea3f3747b2a92fc48456592e77a5b.tar.bz2
poezio-a7826b7b330ea3f3747b2a92fc48456592e77a5b.tar.xz
poezio-a7826b7b330ea3f3747b2a92fc48456592e77a5b.zip
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 “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'poezio/tabs')
-rw-r--r--poezio/tabs/basetabs.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py
index 376f411a..860c1c6a 100644
--- a/poezio/tabs/basetabs.py
+++ b/poezio/tabs/basetabs.py
@@ -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: