Leave non-image links out from Event.previe_links

normal links preview isn't implemented yet, which caused any message
with a link to take at least 256px due to the preview repeater.
This commit is contained in:
miruka 2019-09-10 22:05:06 -04:00
parent 7211dd8fda
commit 60663ed040
2 changed files with 3 additions and 2 deletions

View File

@ -13,7 +13,6 @@
- When qml syntax highlighting supports ES6 string interpolation, use that - When qml syntax highlighting supports ES6 string interpolation, use that
- Fixes - Fixes
- 256 min width when a non-image link preview is present
- Pressing backspace in composer sometimes doesn't work - Pressing backspace in composer sometimes doesn't work
- Message order isn't preserved when sending a first message in a E2E - Message order isn't preserved when sending a first message in a E2E
room, then while keys are being shared sending one with another account, room, then while keys are being shared sending one with another account,

View File

@ -153,11 +153,13 @@ class Event(ModelItem):
if not self.content.strip(): if not self.content.strip():
return [] return []
return [ links = [
(self._get_preview_type(link[0], link[2]), link[2]) (self._get_preview_type(link[0], link[2]), link[2])
for link in lxml.html.iterlinks(self.content) for link in lxml.html.iterlinks(self.content)
] ]
return [l for l in links if l[0] != "page"] # TODO
@staticmethod @staticmethod
def _get_preview_type(el: lxml.html.HtmlElement, link: str) -> str: def _get_preview_type(el: lxml.html.HtmlElement, link: str) -> str:
path = urlparse(link).path.lower() path = urlparse(link).path.lower()