Skip to content

Commit

Permalink
Merge pull request #721 from ppkozlowski/master
Browse files Browse the repository at this point in the history
add simple raven_media renderer
  • Loading branch information
ifedapoolarewaju authored Jan 7, 2019
2 parents b13acbd + d90c4c5 commit 85f5b47
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions browser/js/renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ function renderMessage (message, direction, time, type) {
text: renderMessageAsText,
like: renderMessageAsLike,
media: renderMessageAsImage,
raven_media: renderMessageAsRavenImage,
reel_share: renderMessageAsUserStory, // replying to a user's story
link: renderMessageAsLink
}
Expand Down Expand Up @@ -103,6 +104,22 @@ function renderMessageAsImage (container, message) {
})
}

function renderMessageAsRavenImage (container, message) {
container.classList.add('ig-media');

if (message._params.ravenMedia.image_versions2) {
var url = message._params.ravenMedia.image_versions2.candidates[0].url
var img = dom(`<img src="${url}">`);
img.onload = conditionedScrollToBottom();
container.appendChild(img);

container.addEventListener('click', () => {
showInViewer(dom(`<img src="${url}">`));
})
}

}

function renderMessageAsLike (container) {
renderMessageAsImage(container, 'img/love.png');
}
Expand Down

0 comments on commit 85f5b47

Please sign in to comment.