zulip-flutter icon indicating copy to clipboard operation
zulip-flutter copied to clipboard

Handle alert words (pre-"watched phrases")

Open gnprice opened this issue 9 months ago • 0 comments

I.e., this Zulip feature: https://zulip.com/help/dm-mention-alert-notifications#alert-words

The feature is in the midst of API changes that will also involve a rename. The old/existing API will still be present in Zulip Server 8, though, so we'll need to support it in any case. This issue is for supporting the existing API, which we can go ahead and merge as soon as the implementation is ready; supporting the new/future API will be a separate followup issue.

There are two parts to implementing this:

  • Store and maintain the user's list of alert words. This means taking the data from the initial snapshot, adding it to PerAccountStore, and keeping it up to date with events.
  • Using the alert words in the UI, by highlighting them in messages.

For the second part, see the corresponding code in zulip-mobile, in src/webview/html/processAlertWords.js. Also see the current corresponding code in Zulip web — the zulip-mobile code was copied from there but there may have been changes since then.

We'll want to copy the web and zulip-mobile behavior as closely as possible from a user perspective. That code operates by munging the message's HTML, with regexes. We could probably accomplish something bug-compatible by munging the HTML in the same way, before parsing it… but since we're parsing the HTML anyway, let's do better than that:

  • We'll look for alert words only in the parts that truly are text, where treating a match as an alert word would be appropriate. This means the strings that are held by TextNode, CodeBlockSpanNode, and possibly others.

gnprice avatar May 13 '24 22:05 gnprice