grouppeer status fixes

This commit is contained in:
emdee 2023-12-11 16:00:54 +00:00
parent 65d593cd20
commit 99136cd4e3
6 changed files with 13 additions and 7 deletions

View file

@ -291,7 +291,7 @@ class ContactsManager(ToxSave):
def get_or_create_group_peer_contact(self, group_number, peer_id):
group = self.get_group_by_number(group_number)
peer = group.get_peer_by_id(peer_id)
if peer: # broken?
if peer is None: # broken? is 0 allowed?
if not hasattr(peer, 'public_key') or not peer.public_key:
LOG.error(f'no peer public_key ' + repr(dir(peer)))
else:
@ -300,6 +300,7 @@ class ContactsManager(ToxSave):
return self.get_contact_by_tox_id(peer.public_key)
else:
LOG.warn(f'no peer group_number={group_number} peer_id={peer_id}')
return peer
def check_if_contact_exists(self, tox_id):
return any(filter(lambda c: c.tox_id == tox_id, self._contacts))

View file

@ -84,7 +84,7 @@ class GroupChat(contact.Contact, ToxSave):
LOG_WARN(f"add_peer id={peer_id} > {self._peers_limit}")
return
status_message = f"From {self.name}"
status_message = f"Private in {self.name}"
LOG_TRACE(f"GC.add_peer id={peer_id} status_message={status_message}")
peer = GroupChatPeer(peer_id,
self._tox.group_peer_get_name(self._number, peer_id),

View file

@ -4,8 +4,9 @@ from contacts.contact_menu import GroupPeerMenuGenerator
class GroupPeerContact(contacts.contact.Contact):
def __init__(self, profile_manager, message_getter, peer_number, name, widget, tox_id, group_pk):
super().__init__(profile_manager, message_getter, peer_number, name, str(), widget, tox_id)
def __init__(self, profile_manager, message_getter, peer_number, name, widget, tox_id, group_pk, status_message=None):
if status_message is None: status_message=str()
super().__init__(profile_manager, message_getter, peer_number, name, status_message, widget, tox_id)
self._group_pk = group_pk
def get_group_pk(self):

View file

@ -14,7 +14,10 @@ class GroupPeerFactory(ToxSave):
item = self._create_group_peer_item()
message_getter = self._db.messages_getter(peer.public_key)
group_peer_contact = GroupPeerContact(self._profile_manager, message_getter, peer.id, peer.name,
item, peer.public_key, group.tox_id)
item,
peer.public_key,
group.tox_id,
status_message=peer.status_message)
group_peer_contact.status = peer.status
return group_peer_contact

View file

@ -32,7 +32,8 @@ class ContactItem(QtWidgets.QWidget):
self.status_message.setFont(font)
self.kind = DataLabel(self)
self.kind.setGeometry(QtCore.QRect(50 if mode else 75, 38 if mode else 48, 190, 15 if mode else 20))
font.setBold(True)
font.setBold(False)
font.setItalic(True)
self.kind.setFont(font)
self.connection_status = StatusCircle(self)
self.connection_status.setGeometry(QtCore.QRect(230, -2 if mode else 5, 32, 32))

View file

@ -15,7 +15,7 @@ class PeerItem(QtWidgets.QWidget):
self.nameLabel.setText(name)
if peer.status == TOX_USER_STATUS['NONE']:
if peer.is_current_user:
style = 'QLabel {color: green;}'
style = 'QLabel {color: magenta}'
else:
style = 'QLabel {color: green}'
elif peer.status == TOX_USER_STATUS['AWAY']: