Philipp Hörist pushed to branch master at gajim / gajim

Commits:

1 changed file:

Changes:

  • gajim/common/modules/chatstates.py
    ... ... @@ -74,29 +74,37 @@ class Chatstate:
    74 74
                 return
    
    75 75
     
    
    76 76
             full_jid = stanza.getFrom()
    
    77
    -        jid = full_jid.getStripped()
    
    78 77
     
    
    79 78
             if self._con.get_own_jid().bareMatch(full_jid):
    
    80 79
                 return
    
    81 80
     
    
    82
    -        contact = app.contacts.get_contact_from_full_jid(
    
    83
    -            self._account, str(full_jid))
    
    84
    -        if contact is None or contact.is_gc_contact:
    
    81
    +        contact = app.contacts.get_gc_contact(
    
    82
    +            self._account, full_jid.getStripped(), full_jid.getResource())
    
    83
    +        if contact is None:
    
    84
    +            contact = app.contacts.get_contact_from_full_jid(
    
    85
    +                self._account, str(full_jid))
    
    86
    +        if contact is None:
    
    85 87
                 return
    
    86 88
     
    
    87 89
             if contact.chatstate is None:
    
    88 90
                 return
    
    89 91
     
    
    92
    +        if contact.is_gc_contact:
    
    93
    +            jid = contact.get_full_jid()
    
    94
    +        else:
    
    95
    +            jid = contact.jid
    
    96
    +
    
    90 97
             contact.chatstate = None
    
    91
    -        self._chatstates.pop(contact.jid, None)
    
    92
    -        self._last_mouse_activity.pop(contact.jid, None)
    
    98
    +        self._chatstates.pop(jid, None)
    
    99
    +        self._last_mouse_activity.pop(jid, None)
    
    100
    +        self._last_keyboard_activity.pop(jid, None)
    
    93 101
     
    
    94 102
             log.info('Reset chatstate for %s', jid)
    
    95 103
     
    
    96 104
             app.nec.push_outgoing_event(
    
    97 105
                 NetworkEvent('chatstate-received',
    
    98 106
                              account=self._account,
    
    99
    -                         jid=jid))
    
    107
    +                         contact=contact))
    
    100 108
     
    
    101 109
         def delegate(self, event: Any) -> None:
    
    102 110
             if self._con.get_own_jid().bareMatch(event.jid) or event.sent:
    
    ... ... @@ -133,10 +141,12 @@ class Chatstate:
    133 141
                 return GLib.SOURCE_CONTINUE
    
    134 142
     
    
    135 143
             now = time.time()
    
    136
    -        for jid, time_ in self._last_mouse_activity.items():
    
    144
    +        for jid in list(self._last_mouse_activity.keys()):
    
    145
    +            time_ = self._last_mouse_activity[jid]
    
    137 146
                 current_state = self._chatstates.get(jid)
    
    138 147
                 if current_state is None:
    
    139 148
                     self._last_mouse_activity.pop(jid, None)
    
    149
    +                self._last_keyboard_activity.pop(jid, None)
    
    140 150
                     continue
    
    141 151
     
    
    142 152
                 if current_state in (State.GONE, State.INACTIVE):
    
    ... ... @@ -162,6 +172,7 @@ class Chatstate:
    162 172
                                 contact = contact.as_contact()
    
    163 173
                             else:
    
    164 174
                                 self._last_mouse_activity.pop(jid, None)
    
    175
    +                            self._last_keyboard_activity.pop(jid, None)
    
    165 176
                                 continue
    
    166 177
                     self.set_chatstate(contact, new_chatstate)
    
    167 178
     
    
    ... ... @@ -205,6 +216,7 @@ class Chatstate:
    205 216
                                              chatstate=str(State.GONE)))
    
    206 217
                 self._chatstates.pop(contact.jid, None)
    
    207 218
                 self._last_mouse_activity.pop(contact.jid, None)
    
    219
    +            self._last_keyboard_activity.pop(contact.jid, None)
    
    208 220
                 return
    
    209 221
     
    
    210 222
             if not contact.is_groupchat():