Only send a formatted_body if it's truly needed

This commit is contained in:
miruka 2019-07-19 18:13:04 -04:00
parent 2ce45e8059
commit a10a395e0b
2 changed files with 10 additions and 9 deletions

View File

@ -11,17 +11,19 @@
- Room Sidepane - Room Sidepane
- When qml syntax highlighting supports string interpolation, use them - When qml syntax highlighting supports string interpolation, use them
- Bug fixes - Fixes
- Past events loading (limit 100) freezes the GUI - need to move upsert func - Past events loading (limit 100) freezes the GUI - need to move upsert func
to a WorkerScript to a WorkerScript
- `MessageDelegate.qml:63: TypeError: 'reloadPreviousItem' not a function` - `MessageDelegate.qml:63: TypeError: 'reloadPreviousItem' not a function`
- Horrible performance for big rooms - Horrible performance for big rooms
- UI - UI
- Show error box if uploading avatar fails
- EditAccount page: - EditAccount page:
- Device settings - Device settings
- Multiaccount aliases: - Multiaccount aliases:
- Warn when overwriting another alias - Warn when overwriting another alias
- Forbid spaces?
- Add an explanation tooltip - Add an explanation tooltip
- Improve avatar tooltips position, add stuff to room tooltips (last msg?) - Improve avatar tooltips position, add stuff to room tooltips (last msg?)
- Accept drag and dropping a picture in account settings to set avatar - Accept drag and dropping a picture in account settings to set avatar
@ -77,7 +79,6 @@
- Client improvements - Client improvements
- Set Qt.application.* stuff from C++ - Set Qt.application.* stuff from C++
- Don't send a formatted_text if it's just `<p>plaintext</p>`
- [debug mode](https://docs.python.org/3/library/asyncio-dev.html) - [debug mode](https://docs.python.org/3/library/asyncio-dev.html)
- Initial sync filter and lazy load, see weechat-matrix `_handle_login()` - Initial sync filter and lazy load, see weechat-matrix `_handle_login()`
- See also `handle_response()`'s `keys_query` request - See also `handle_response()`'s `keys_query` request

View File

@ -155,12 +155,12 @@ class MatrixClient(nio.AsyncClient):
async def send_markdown(self, room_id: str, text: str) -> None: async def send_markdown(self, room_id: str, text: str) -> None:
content = { content = {"body": text, "msgtype": "m.text"}
"body": text, to_html = HTML_FILTER.from_markdown(text)
"formatted_body": HTML_FILTER.from_markdown(text),
"format": "org.matrix.custom.html", if to_html not in (text, f"<p>{text}</p>"):
"msgtype": "m.text", content["format"] = "org.matrix.custom.html"
} content["formatted_body"] = to_html
TimelineMessageReceived( TimelineMessageReceived(
event_type = nio.RoomMessageText, event_type = nio.RoomMessageText,
@ -168,7 +168,7 @@ class MatrixClient(nio.AsyncClient):
event_id = f"local_echo.{uuid4()}", event_id = f"local_echo.{uuid4()}",
sender_id = self.user_id, sender_id = self.user_id,
date = datetime.now(), date = datetime.now(),
content = content["formatted_body"], content = to_html,
is_local_echo = True, is_local_echo = True,
) )