Properly hide unread channel indicators when there are no unread channels

Этот коммит содержится в:
hmhealey
2015-09-14 16:56:20 -04:00
родитель e644b53b72
Коммит 8d0c69aec6

Просмотреть файл

@@ -274,26 +274,32 @@ export default class Sidebar extends React.Component {
this.updateUnreadIndicators(); this.updateUnreadIndicators();
} }
updateUnreadIndicators() { updateUnreadIndicators() {
var container = $(React.findDOMNode(this.refs.container)); const container = $(React.findDOMNode(this.refs.container));
const topUnreadIndicator = $(React.findDOMNode(this.refs.topUnreadIndicator));
const bottomUnreadIndicator = $(React.findDOMNode(this.refs.bottomUnreadIndicator));
if (this.firstUnreadChannel) { if (this.firstUnreadChannel) {
var firstUnreadElement = $(React.findDOMNode(this.refs[this.firstUnreadChannel])); var firstUnreadElement = $(React.findDOMNode(this.refs[this.firstUnreadChannel]));
if (firstUnreadElement.position().top + firstUnreadElement.height() < 0) { if (firstUnreadElement.position().top + firstUnreadElement.height() < 0) {
$(React.findDOMNode(this.refs.topUnreadIndicator)).css('display', 'initial'); topUnreadIndicator.css('display', 'initial');
} else { } else {
$(React.findDOMNode(this.refs.topUnreadIndicator)).css('display', 'none'); topUnreadIndicator.css('display', 'none');
} }
} else {
topUnreadIndicator.css('display', 'none');
} }
if (this.lastUnreadChannel) { if (this.lastUnreadChannel) {
var lastUnreadElement = $(React.findDOMNode(this.refs[this.lastUnreadChannel])); var lastUnreadElement = $(React.findDOMNode(this.refs[this.lastUnreadChannel]));
if (lastUnreadElement.position().top > container.height()) { if (lastUnreadElement.position().top > container.height()) {
$(React.findDOMNode(this.refs.bottomUnreadIndicator)).css('display', 'initial'); bottomUnreadIndicator.css('display', 'initial');
} else { } else {
$(React.findDOMNode(this.refs.bottomUnreadIndicator)).css('display', 'none'); bottomUnreadIndicator.css('display', 'none');
} }
} else {
bottomUnreadIndicator.css('display', 'none');
} }
} }
createChannelElement(channel, index) { createChannelElement(channel, index) {