zulip / zulip-flutter

Future Zulip client using Flutter
Apache License 2.0
173 stars 157 forks source link

Local echo when sending messages #576

Open gnprice opened 6 months ago

gnprice commented 6 months ago

When you send a message, the message should eventually show up in the message list you're looking at: our sendMessage API request completes, then the server sends us a MessageEvent reflecting the new message. If you have a good network connection to the server and the server is functioning normally, this all happens pretty quickly.

But when that isn't the case, it's important for us to give some feedback in the UI to let the user know that their message is being sent. For example if we don't do that, the user may think it didn't work and they need to manually try again (by retyping the message); that's annoying to do and then leads to an unintended duplicate message. Here's a report of that in zulip-mobile, where we do show such feedback but apparently have a bug where it can be missing: https://github.com/zulip/zulip-mobile/issues/2374#issuecomment-1851329774

Currently in this beta app we have no such feedback at all. In web and in zulip-mobile, when you hit send we immediately show a "local echo" of the message: the client parses the Markdown for itself, turns that into HTML attempting to mimic what the server will do, and renders it. (Plus a subtle cue to indicate the message isn't yet finished sending.) We should do something similar in this app.

The tricky part here is the implementation of Zulip's Markdown-based syntax. There are a few different ways this could happen:

Related issues

dalonzoo commented 6 months ago

What if the App warns the user (with a pop-up) that due to connection problems sending messages is taking too long?Meanwhile the App will keep trying to send the message until the response from server.

gnprice commented 6 months ago

A pop-up like that could be a potential alternative quick hack, in place of the quick hack mentioned above:

We could temporarily do a quick hack where we don't parse the message's markup at all: we either say something generic like "(Sending message…)", or possibly we show the raw message source as plain text.

But to fully resolve this issue we'll still want something smoother, like we have in zulip-mobile and Zulip web. Like this:

We can transcribe Zulip web's Markdown implementation into Dart. Can probably get a usable version if I give it a couple days' focused work.