Skip to content

Instantly share code, notes, and snippets.

@oliversisson
oliversisson / GiftedMessengerContainer.js
Created April 27, 2016 16:47
Improvement to setMessageStatus. It is much more terse. It is more functional: using a map, rather than a for-loop
setMessageStatus(uniqueId, status) {
return this.state.messages.map(function(message) {
if (message.uniqueId !== uniqueId) {
return message;
}
return Object.assign({}, message, {status});
});
}
(function() {
var currentScroll = window.scrollY;
var currentlyScrolling = false;
var runOnScroll = function(evt) {
if (currentlyScrolling) {
// preventDefault doesn't seem to work
window.scrollTo(window.X, currentScroll);
}
};