nioc / xmpp-web

Lightweight web chat client for XMPP server
GNU Affero General Public License v3.0
142 stars 20 forks source link

feat(chat states): Send chat state (XEP-0085) #98

Closed nioc closed 1 year ago

nioc commented 1 year ago

Opt-out for composing/pauses/active states Opt-in for inactive state Save user preferences to local storage And add icons to presence controller

57

nioc commented 1 year ago

New UI for the presence controller with opt-in/out and icons:

image

nioc commented 1 year ago

@Ppjet6 If I may ask you to take a quick look at this one, that would be very nice of you 😄 I would like to release the 0.9.12 with it.

Ppjet6 commented 1 year ago

I have to admit I don't know your framework very much, and don't know this feature really well either.

Because you have an option not to send inactive states, I guess you'll want to replace every <inactive/> payload with <active/> when it's disabled.

I tried to run your branch but the stars won't align today and nothing is working. :( I can have another look tomorrow if you want.

nioc commented 1 year ago

When the user click on another room or contact chat, If he opt-in the "send inactive chat state", it will send <inactive xmlns='http://jabber.org/protocol/chatstates'/> , otherwise it is not sent.

For composing (and paused) states it is when user is typing (and after a delay), only if the user does not opt-out for it.

I hope I didn't break anything. I will attach a release.tar.gz in few hours for testing.

nioc commented 1 year ago

Here the draft release xmpp-web-57-send-chat-states-xep-0085.tar.gz

Also the docker image: docker pull nioc/xmpp-web:57-send-chat-states-xep-0085

Ppjet6 commented 1 year ago

Looks like it's working alright! It's just sending chatstates right? Not reading.

Ppjet6 commented 1 year ago

I realized it's not "clearing" the <paused/> state over the wire? A client may keep displaying it until it receives something else from XMPP Web.

nioc commented 1 year ago

Yes it just do this 😄 If you mean by "reading": displaying chat states, it is already implemented with an icon on the top bar: 20230215_181334 If you mean read Mark it is another XEP 0333 on #4.

Yes it leaves in paused until you send or erase (active) or type again (composing). It is what I understood from the XEP spec. Testing with Gajim which removes the state itself after a while without receiving anything from xmpp-web.

nioc commented 1 year ago

Pseudo code :

On input (typing or erasing)
      Do nothing and finish if opt-out
      remove `pause` timer 
      If composing message not empty
         Prepare timer: in 15s send `paused`
         If already sent `composing` do nothing
         Send`composing`
      Else (cleared draft) 
         Send `active`
Ppjet6 commented 1 year ago

The issue with leaving the <paused/> state hanging is that some clients don't clear it up themselves. The source of truth being the sending client and not what they think of the sending client. That's also more state to manage for the receiving client when you could just read and display what comes.

As for "reading", I meant displaying what other clients send you. And I don't think you do (and that's ok!)

nioc commented 1 year ago

I agree it is not great, but it would only appears when a user leave unfinished his message without sending or erasing (the paused status is, in this case, relevant). Reading the specs make me think that we should not sending other status. The only workaround would be to send an active after a longer delay, but I propose releasing as-is and reacting if there are issues.