morethanwords / tweb

Telegram Web K, GPL v3
https://web.telegram.org/k/
GNU General Public License v3.0
1.86k stars 596 forks source link

[BUG] User status keeps appending "when" while the user is typing #311

Closed richardrigutins closed 8 months ago

richardrigutins commented 8 months ago

Describe the bug On the User Info panel, when the user is typing or selecting a sticker, a series of when? strings keep getting added to the user status while the user keeps typing.

Only a single when? is displayed instead when the status changes to a different value (online, last seen recently).

To Reproduce Steps to reproduce the behavior:

  1. Open a chat with a user.
  2. Click on the user name or profile picture on the top bar to open the User Info panel.
  3. Have the user type a message for some seconds.
  4. The user status is displayed as typing, and multiple when? elements are progressively appended to the status.

Expected behavior Only a single when? element should be displayed.

Screenshots image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context The behavior could be caused by a conflict between the code block that appends the when element in peerProfile.ts:

          const when = i18n('StatusHiddenShow');
          when.classList.add('show-when');
          attachClickEvent(when, (e) => {
            cancelEvent(e);
            PopupElement.createPopup(PopupToggleReadDate, peerId, 'lastSeen');
          });
          this.subtitle.append(when);

and this check inside setPeerStatus in appImManager.ts:

      const typingContainer = element.querySelector('.peer-typing-container') as HTMLElement;
      if(typingContainer && await this.getPeerTyping(peerId, typingContainer)) {
        // log('already have a status');
        return;
      }

Because of this check, the subtitle element doesn't get replaced while the user is typing, but a when element keeps getting appended to it. When the user is not typing, the subtitle is replaced after every update, and only a single when element is displayed.

Waynaade commented 7 months ago

Describe the bug On the User Info panel, when the user is typing or selecting a sticker, a series of when? strings keep getting added to the user status while the user keeps typing.

Only a single when? is displayed instead when the status changes to a different value (online, last seen recently).

To Reproduce Steps to reproduce the behavior:

  1. Open a chat with a user.
  2. Click on the user name or profile picture on the top bar to open the User Info panel.
  3. Have the user type a message for some seconds.
  4. The user status is displayed as typing, and multiple when? elements are progressively appended to the status.

Expected behavior Only a single when? element should be displayed.

Screenshots image

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome, Edge
  • Version 122

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context The behavior could be caused by a conflict between the code block that appends the when element in peerProfile.ts:

          const when = i18n('StatusHiddenShow');
          when.classList.add('show-when');
          attachClickEvent(when, (e) => {
            cancelEvent(e);
            PopupElement.createPopup(PopupToggleReadDate, peerId, 'lastSeen');
          });
          this.subtitle.append(when);

and this check inside setPeerStatus in appImManager.ts:

      const typingContainer = element.querySelector('.peer-typing-container') as HTMLElement;
      if(typingContainer && await this.getPeerTyping(peerId, typingContainer)) {
        // log('already have a status');
        return;
      }

Because of this check, the subtitle element doesn't get replaced while the user is typing, but a when element keeps getting appended to it. When the user is not typing, the subtitle is replaced after every update, and only a single when element is displayed.

Ok

Waynaade commented 7 months ago

Good