Commit graph

107 commits

Author SHA1 Message Date
Michael Telatynski
72a83a8e6e Add mount-guards to MImageBody
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2019-08-09 14:51:07 +01:00
Slavi Pantaleev
3f60b4336f Do not try to request thumbnails with non-integer widths
Issue described in https://github.com/vector-im/riot-web/issues/9690.

With certain `window.devicePixelRatio` values
(e.g.  `1.5789473684210527`), the calculated thumb width/height
would be a non-integer value.

Passing such values to `client.mxcUrlToHttp()` causes it to
generate URLs to the thumbnail API with non-integer values.
As per the spec, non-integer values are forbidden for that API and a
400 HTTP response is returned (`Query parameter b'width' must be an
integer`).

Fixing matrix-js-sdk's `mxcUrlToHttp()` to sanitize such values
would also be a good idea and likely fix more than just matrix-react-sdk
and riot-web. Still, it feels like matrix-react-sdk should play nice
as well, and not request thumbnails for weird widths/heights.

Signed-off-by: Slavi Pantaleev <slavi@devture.com>
2019-05-27 11:06:10 +03:00
J. Ryan Stinnett
f19e70c219 Add comment about thumbnailing for GIFs 2019-05-14 13:55:38 +01:00
J. Ryan Stinnett
7881369b98 Always thumbnail for GIFs
When displaying a GIF, we always want to thumbnail so that we can properly
respect the user's GIF autoplay setting (which relies on thumbnailing to produce
the static preview image).

Fixes https://github.com/vector-im/riot-web/issues/9658
2019-05-13 18:28:57 +01:00
J. Ryan Stinnett
9d9a41b263 Save content.info as a local for readability 2019-05-13 18:00:52 +01:00
Bruno Windels
45f3282b1b cleanup and linting 2019-04-08 14:57:39 +02:00
Bruno Windels
f1b00dff35 Merge branch 'develop' into matthew/retina 2019-04-05 13:35:54 +02:00
Bruno Windels
4e382b1dd9 rename onWidgetLoad to onHeightChanged
as it's easy to confuse it with room widgets, but has nothing to do with it.
2019-03-07 17:02:19 +01:00
Matthew Hodgson
8511bc27cc only request thumbs on retina if the original image is too big to be used as a thumbnail 2019-01-20 15:35:16 +00:00
J. Ryan Stinnett
20e296b20e Convert image URLs in React to require calls
This allows Webpack to insert the proper image URL after builds steps like
adding a hash and so on. The path you supply to `require` is relative to the JS
source file, just like any other would be.
2019-01-17 22:06:49 -06:00
Matthew Hodgson
577c411a39 experimental fix for https://github.com/vector-im/riot-web/issues/2985
needs server to support 1600x1200 thumbnails for retina large ones.
ideally need to cap maximum thumbnail size to 800x600 rather than expand to arbitrary widths.
need to check that luke's funky timeline code doesn't get confused between naturalWidth and infoWidth etc.
also need to consider whether to encode a resolution metric in the event rather than lying about resolution.
2019-01-14 17:10:22 +00:00
Maxwell Kepler
5d35ce9449 Changed letter case. 2018-10-24 19:06:48 +01:00
Maxwell Kepler
5e9db3647a Fixed minor typo in comment 2018-10-22 21:03:39 +01:00
Maxwell Kepler
54f9231582 Added badge to GIFs (https://github.com/vector-im/riot-web/issues/7344) 2018-10-22 20:57:58 +01:00
Bruno Windels
debcc20604 also show spinner on new CATCHUP state 2018-08-30 15:39:48 +02:00
Michael Telatynski
fffb8379d8
delint MImageBody, fixes anonymous class and hyphenated style keys which made react cry
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2018-06-19 08:37:11 +01:00
Luke Barnard
2eb23ed234 Add loadedImageDimensions to initial state 2018-06-14 15:53:49 +01:00
Luke Barnard
2d14d51ecb Handle images without width/height info correctly
Prior to #1912, height fix up of image events without an `info` in their
content would fail, setting `style.height = null + "px"`.

Now that all thumbnail sizing is done through one path, we can fix the
same problem for all cases (images, stickers, e2e/non-e2e) by handling
images without `info` correctly.

At the bare minimum, we use a null-guard that will make sure an image
without an `info` does not appear in the timeline (as a spinner or
otherwise until loaded). When loaded, we size it like any other image
by using the natural dimensions of the loaded image in place of `info`.

Note that we do not apply the same logic to images that *do* specify an
`info` with `w` and `h` keys. If the aspect ratio of the image does not
match that of the event, we use the one in `info` even when the image
has loaded.
2018-06-14 15:44:55 +01:00
Luke Barnard
c8d233c0a6 If unspecified, don't crash if missing thumbnail info
applies to stickers/images.

We might want to consider to do that is better than assuming a aspect
ratio of 600 x 800 (4:3).
2018-06-14 14:19:30 +01:00
Luke Barnard
2120858e5f
Merge branch 'develop' into luke/kill-mimage-fixupheight 2018-06-11 14:24:40 +01:00
Travis Ralston
033c41a2a8 Align pinned message contents and reduce image size
Fixes https://github.com/vector-im/riot-web/issues/5421

Signed-off-by: Travis Ralston <travpc@gmail.com>
2018-05-26 18:40:48 -06:00
Luke Barnard
c249bee9b5 Grammar 2018-05-22 16:09:54 +01:00
Luke Barnard
fb5dd4a410 Remove spurious fixupHeight 2018-05-22 10:46:10 +01:00
Luke Barnard
e4f8c09c32 Only include placeholder in DOM when necessary 2018-05-22 10:43:16 +01:00
Luke Barnard
e9ae3de00f Merge branch 'develop' into luke/kill-mimage-fixupheight 2018-05-21 17:15:54 +01:00
Luke Barnard
836dc8b0ef Factor out all shared logic between MStickerBody and MImageBody
The benefits of this:
 - One code path for determining spinner/placeholder and it's position
   for loading images/stickers. This includes spinner used in e2e
   decryption of images.
 - Very small definition for MStickerBody, only overriding the minimal
   differences is has from MImageBody.

The disadvantages:
 - Slightly more complicated MImageBody, but hopefully not less
   readable.
2018-05-21 16:59:13 +01:00
Luke Barnard
015093b371 Move inline style to stylesheet 2018-05-18 11:34:41 +01:00
Luke Barnard
7e7e2a7473 Add more comments to explain thumbnail sizing 2018-05-18 10:27:22 +01:00
Luke Barnard
d11442de04 Adjust comment 2018-05-18 10:15:59 +01:00
Luke Barnard
bbcf2fea53 Fix e2e image thumbnail spinner containing box correct size 2018-05-18 09:47:49 +01:00
Luke Barnard
b28ed6075b Implement slightly hacky CSS soln. to thumbnail sizing
As the slightly nicer alternative to fixupHeight being applied once
we actually have a timelineWidth.

The niceness comes from not needing timelineWidth, which means we can
implement at render time with CSS. (Despite still calculating aspect
ratios when we render.)
2018-05-17 18:15:34 +01:00
David Baker
a7006307bf Call afterComponentDidMount() after componentDidMount 2018-05-17 16:50:16 +01:00
David Baker
e53497421e Fix image size jumping regression
Fixes https://github.com/vector-im/riot-web/issues/6654
2018-05-17 16:47:17 +01:00
Matthew Hodgson
af5be5c36c appease the fascist linter 2018-05-05 22:28:09 +01:00
Matthew Hodgson
14bcfdd5c6 fix NPE 2018-05-05 22:08:37 +01:00
Matthew Hodgson
5749fbcff9
Merge pull request #1864 from matrix-org/matthew/blob_urls
Switch back to using blob URLs for rendering e2e attachments
2018-04-30 19:01:58 +01:00
Matthew Hodgson
db5fc53853 final comment 2018-04-29 04:53:32 +01:00
Matthew Hodgson
be523b3edc lint 2018-04-29 04:31:30 +01:00
Matthew Hodgson
551d3ebda0 correctly fix up thumbnail height onload.
fixes https://github.com/vector-im/riot-web/issues/6492, although popping is inevitable in
the current implementation as it only fixes up the thumbnail size once the image has loaded.
2018-04-29 04:28:15 +01:00
Matthew Hodgson
731f1fa7d3 clarify another scrolljump bug 2018-04-29 04:00:02 +01:00
Matthew Hodgson
c254d043c5 fix ugly img errors and correctly render SVG thumbnails
Fixes https://github.com/vector-im/riot-web/issues/6271
Fixes https://github.com/vector-im/riot-web/issues/1341
2018-04-29 03:58:17 +01:00
Matthew Hodgson
9c5407c21f revokeObjectURLs 2018-04-29 03:17:55 +01:00
Matthew Hodgson
9701fd32b7 switch back to blob urls for rendering e2e attachments
Based on @walle303's work at https://github.com/matrix-org/matrix-react-sdk/pull/1820
Deliberately reverts 8f778f54fd
Mitigates XSS by whitelisting the mime-types of the attachments so that malicious ones
should not be recognised and executed by the browser.
2018-04-29 03:07:31 +01:00
David Baker
f5956c87f6 Bind onImageError in constructor
Tt uses `this` but wasn't bound anywhere so the error handler was
just throwing an exception.
2018-04-23 18:14:59 +01:00
Richard Lewis
7e062090de Cleanup timeout before unmount. 2018-03-09 21:12:56 +00:00
Richard Lewis
c59dd5b840 Add placeholders for sticker images (and fancy transitions). 2018-03-08 12:31:01 +00:00
Richard Lewis
5ca0fc3ab5 Make MStickerBody extend MImageBody. 2018-02-26 14:01:33 +00:00
Luke Barnard
cf4ae681f4
Offline mode (#1723)
* Allow the client to run without connection to HS (i.e. using indexeddb)

Allows running without having pushRules (it's safe not to have these 
when running from indexeddb sync.)

This means rooms will be displayed with "unknown" notifcation state.

This assumes anything that uses the push rules will get pushRule state
again when the client starts syncing again.

For recovering from being disconnected, 
* If an avatar has fallen back, try again on reconnection
* If a thumbnail image failed to load, retry on reconnect
* Load joined groups when reconnecting

Update tests to give MELS a context.matrixClient
2018-02-06 17:50:53 +00:00
Aidan Gauland
35780f5ae0 Remove use of deprecated React.PropTypes
Replace all uses of React.PropTypes with PropTypes and importing PropTypes from
'prop-types'.
2017-12-26 14:03:18 +13:00
Luke Barnard
641add4964 Fix one kind of scroll jump
by calling onWidgetLoad when the <img> in MImageBody loads
2017-12-01 14:18:13 +00:00