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
- 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
to a WorkerScript
- `MessageDelegate.qml:63: TypeError: 'reloadPreviousItem' not a function`
- Horrible performance for big rooms
- UI
- Show error box if uploading avatar fails
- EditAccount page:
- Device settings
- Multiaccount aliases:
- Warn when overwriting another alias
- Forbid spaces?
- Add an explanation tooltip
- Improve avatar tooltips position, add stuff to room tooltips (last msg?)
- Accept drag and dropping a picture in account settings to set avatar
@ -77,7 +79,6 @@
- Client improvements
- 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)
- Initial sync filter and lazy load, see weechat-matrix `_handle_login()`
- 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:
content = {
"body": text,
"formatted_body": HTML_FILTER.from_markdown(text),
"format": "org.matrix.custom.html",
"msgtype": "m.text",
}
content = {"body": text, "msgtype": "m.text"}
to_html = HTML_FILTER.from_markdown(text)
if to_html not in (text, f"<p>{text}</p>"):
content["format"] = "org.matrix.custom.html"
content["formatted_body"] = to_html
TimelineMessageReceived(
event_type = nio.RoomMessageText,
@ -168,7 +168,7 @@ class MatrixClient(nio.AsyncClient):
event_id = f"local_echo.{uuid4()}",
sender_id = self.user_id,
date = datetime.now(),
content = content["formatted_body"],
content = to_html,
is_local_echo = True,
)