Skip to content

Commit

Permalink
webview: Do not open YouTube and Vimeo links in Lightbox.
Browse files Browse the repository at this point in the history
Fixes #2895.

We do not support video in the Lightbox screen, nor do we intend to
(no benefit).  Instead treat the links as normal ones if they are
to a video on YouTube or Vimeo.  This matches the behavior of many
other mobile apps.

These are the two types of video links the webapp embeds in messages,
as seen in zulip/zulip's static/js/lightbox.js .  This logic is kind
of fragile, though; for example, we still do the wrong thing on images
inside an embedded tweet.
  • Loading branch information
borisyankov authored and gnprice committed Oct 1, 2018
1 parent 9fc7698 commit f0a4709
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ rules:
pre, blockquote, li, br, emojis, chatboxes, userlist, middleware, trunc, pushable,
ios, md, caughtup, autocompleted, substring, png, ds, videocam, unmount, github,
facebook, idx, aaa, bbb, ccc, ddd, eee, fff, abcd, aaaaaa, ffffff, 24cac2, src,
attribs, charset, utf, urlencoded, htmlparser, ul, ol, chatbubbles,
attribs, charset, utf, urlencoded, htmlparser, ul, ol, chatbubbles, vimeo,
nonexisting, primarytext, autocomple, stringify, backend, Zoe, Menlo, ok, py,
todo, Mc, lodash, selectable, isequal, lightgray, tc, zulipchat, prepend, pierre,
allen, jan, donald, jane, unicode, joe, unescape, dan, abramov, lang, bool,
Expand All @@ -121,7 +121,7 @@ rules:
gcm, unstarMessage, Unstar, wildcard_mentioned, lightbox, resize, remobile, tz,
multiline, uniqby, zoe, localizable, appid, apns, Entypo, msup, mrow, webview,
js, timerow, reselect, addons, cancelable, gravatar_hash, pms, msgs, collapsable,
const, wildcard, reactotron, camelcase, hydrator, perf, stacktrace, Dir, fs,
const, wildcard, reactotron, camelcase, hydrator, perf, stacktrace, Dir, fs, youtube,
avoider, octicons, centerer, ldap, gravatar, identicon, blueimp, filename, wildcards,
jpeg, jpg, tif, mov, notif, diag, bmp, viewport, scalable, polyfill, rect, touchstart,
touchend, touchmove, remoteuser, sso, submessages, nbsp, args, px, na, heic,
Expand Down
2 changes: 1 addition & 1 deletion src/webview/js/generatedEs3.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ documentBody.addEventListener('click', function (e) {
return;
}
if (e.target.matches('a[target="_blank"] > img')) {
if (e.target.matches('a[target="_blank"] > img') && !e.target.matches('.youtube-video > a[target="_blank"] > img') && !e.target.matches('.vimeo-video > a[target="_blank"] > img')) {
sendMessage({
type: 'image',
src: e.target.parentNode.getAttribute('href'),
Expand Down
6 changes: 5 additions & 1 deletion src/webview/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ documentBody.addEventListener('click', e => {
return;
}

if (e.target.matches('a[target="_blank"] > img')) {
if (
e.target.matches('a[target="_blank"] > img')
&& !e.target.matches('.youtube-video > a[target="_blank"] > img')
&& !e.target.matches('.vimeo-video > a[target="_blank"] > img')
) {
sendMessage({
type: 'image',
src: e.target.parentNode.getAttribute('href'),
Expand Down

0 comments on commit f0a4709

Please sign in to comment.