fsavje / math-with-slack

Rendered math (MathJax) with Slack's desktop client
MIT License
431 stars 62 forks source link

Fix #49 and #51, might have performance implications #54

Closed thisiscam closed 3 years ago

thisiscam commented 4 years ago

An attempt to fix #49 and #51

The problem (I think) was that the MutationObserver is somehow interfering with the keyboard space key event. Since the MutationObserver was applied on $(#message_container)s, in Threads view, this also included the input text field attached to each thread.

In this pull request, I resorted to using DOMNodeInserted event, which doesn't seem to cause trouble with keyboard (though according to internet this should be deprecated for performance reason). As a compensation (I hope), in the event handler, I only attached IntersectionObserver which watches for DOM entry, and then mathjax the relevant pieces of text (instead of the entire message container as before).

Edit: Just realized that https://github.com/thisiscam/math-with-slack/blob/v3/math-with-slack.py#L184 also hacks away the problem of Slack rewriting the local settings file. Hacky but one-liner is always worth it 💯