diff options
author | Christopher Speller <crspeller@gmail.com> | 2015-09-09 08:22:06 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2015-09-09 08:22:06 -0400 |
commit | b15b297bb3b5ae6dc6d336b0a333e967b31092bf (patch) | |
tree | b48a89da07b0c6b1d07692c532b85ee745cb45f0 /web/react/components/channel_loader.jsx | |
parent | 64d4890a4109618b383f7cfe1acc541bd72a0899 (diff) | |
parent | 5c0680397de9d3cfd0018743e0b1d58dfbdca25d (diff) | |
download | chat-b15b297bb3b5ae6dc6d336b0a333e967b31092bf.tar.gz chat-b15b297bb3b5ae6dc6d336b0a333e967b31092bf.tar.bz2 chat-b15b297bb3b5ae6dc6d336b0a333e967b31092bf.zip |
Merge pull request #623 from mattermost/plt-35
PLT-35 Add post list container to hold mounted post lists for faster rendering/channel switching.
Diffstat (limited to 'web/react/components/channel_loader.jsx')
-rw-r--r-- | web/react/components/channel_loader.jsx | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/web/react/components/channel_loader.jsx b/web/react/components/channel_loader.jsx index 8e8ed3f73..ce6f60f87 100644 --- a/web/react/components/channel_loader.jsx +++ b/web/react/components/channel_loader.jsx @@ -17,6 +17,8 @@ export default class ChannelLoader extends React.Component { constructor(props) { super(props); + this.intervalId = null; + this.onSocketChange = this.onSocketChange.bind(this); this.state = {}; @@ -35,10 +37,12 @@ export default class ChannelLoader extends React.Component { PostStore.clearPendingPosts(); /* Set up interval functions */ - setInterval( + this.intervalId = setInterval( function pollStatuses() { AsyncClient.getStatuses(); - }, 30000); + }, + 30000 + ); /* Device tracking setup */ var iOS = (/(iPad|iPhone|iPod)/g).test(navigator.userAgent); @@ -49,12 +53,12 @@ export default class ChannelLoader extends React.Component { /* Set up tracking for whether the window is active */ window.isActive = true; - $(window).focus(function windowFocus() { + $(window).on('focus', function windowFocus() { AsyncClient.updateLastViewedAt(); window.isActive = true; }); - $(window).blur(function windowBlur() { + $(window).on('blur', function windowBlur() { window.isActive = false; }); @@ -84,6 +88,54 @@ export default class ChannelLoader extends React.Component { Utils.changeCss('.btn.btn-primary:hover, .btn.btn-primary:active, .btn.btn-primary:focus', 'background: ' + Utils.changeColor(user.props.theme, +10) + ';'); $('.team__header').addClass('theme--gray'); } + + /* Setup global mouse events */ + $('body').on('click.userpopover', function popOver(e) { + if ($(e.target).attr('data-toggle') !== 'popover' && + $(e.target).parents('.popover.in').length === 0) { + $('.user-popover').popover('hide'); + } + }); + + $('body').on('mouseenter mouseleave', '.post', function mouseOver(ev) { + if (ev.type === 'mouseenter') { + $(this).parent('div').prev('.date-separator, .new-separator').addClass('hovered--after'); + $(this).parent('div').next('.date-separator, .new-separator').addClass('hovered--before'); + } else { + $(this).parent('div').prev('.date-separator, .new-separator').removeClass('hovered--after'); + $(this).parent('div').next('.date-separator, .new-separator').removeClass('hovered--before'); + } + }); + + $('body').on('mouseenter mouseleave', '.post.post--comment.same--root', function mouseOver(ev) { + if (ev.type === 'mouseenter') { + $(this).parent('div').prev('.date-separator, .new-separator').addClass('hovered--comment'); + $(this).parent('div').next('.date-separator, .new-separator').addClass('hovered--comment'); + } else { + $(this).parent('div').prev('.date-separator, .new-separator').removeClass('hovered--comment'); + $(this).parent('div').next('.date-separator, .new-separator').removeClass('hovered--comment'); + } + }); + + /* Setup modal events */ + $('.modal').on('show.bs.modal', function onShow() { + $('.modal-body').css('overflow-y', 'auto'); + $('.modal-body').css('max-height', $(window).height() * 0.7); + }); + } + componentWillUnmount() { + clearInterval(this.intervalId); + + $(window).off('focus'); + $(window).off('blur'); + + SocketStore.removeChangeListener(this.onSocketChange); + + $('body').off('click.userpopover'); + $('body').off('mouseenter mouseleave', '.post'); + $('body').off('mouseenter mouseleave', '.post.post--comment.same--root'); + + $('.modal').off('show.bs.modal'); } onSocketChange(msg) { if (msg && msg.user_id && msg.user_id !== UserStore.getCurrentId()) { |