Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Use download url on shot if mobile. (#4876) (#4921)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenba authored and jaredhirsch committed Sep 20, 2018
1 parent 55cd022 commit b4591cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/METRICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ These are events that an add-on user can encounter on a shot they own
30. [x] Click "Copy Image Text" on the context menu `web/copy-image-text/context-menu`
32. [x] Click Feedback/mailto button `start-feedback/footer`
31. [x] Click on clip `web/goto-clip/content`
31. [x] Click on clip in a mobile browser `web/mobile-download/content`
32. [x] Click the download button `web/download/navbar`
33. [x] Visit an image directly, when the image isn't embedded directly in a Screenshots shot page, `web/visit/direct-view-owner`
34. [x] View an image directly, when the image is being shown as part of a Facebook/Twitter style preview (the og:image or twitter:image), `web/visit/direct-view-embedded-owner`
Expand Down
13 changes: 11 additions & 2 deletions server/src/pages/shot/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,23 @@ class Clip extends React.Component {
return null;
}
const node = <img id="clipImage" style={{height: "auto", width: Math.floor(clip.image.dimensions.x) + "px", maxWidth: "100%" }} ref={clipImage => this.clipImage = clipImage} src={ clip.image.url } alt={ clip.image.text } />;
const clipUrl = this.props.isMobile
? this.props.downloadUrl
: clip.image.url;
return <div ref={clipContainer => this.clipContainer = clipContainer} className="clip-container">
{ this.copyTextContextMenu() }
<a href={ clip.image.url } onClick={ this.onClickClip.bind(this) } contextMenu="clip-image-context">
<a href={ clipUrl } onClick={ this.onClickClip.bind(this) } contextMenu="clip-image-context">
{ node }
</a>
</div>;
}

onClickClip() {
sendEvent("goto-clip", "content", {useBeacon: true});
if (this.props.isMobile) {
sendEvent("mobile-download", "content", {useBeacon: true});
} else {
sendEvent("goto-clip", "content", {useBeacon: true});
}
// Allow default action to continue
}

Expand Down Expand Up @@ -84,6 +91,8 @@ class Clip extends React.Component {

Clip.propTypes = {
clip: PropTypes.object,
isMobile: PropTypes.bool,
downloadUrl: PropTypes.string,
};

class Head extends React.Component {
Expand Down

0 comments on commit b4591cf

Please # to comment.