2015-12-22 07:34:24 -08:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-30 07:50:43 -08:00
|
|
|
const React = require('react');
|
|
|
|
const ReactDOM = require('react-dom');
|
|
|
|
const ReactBootstrap = require('react-bootstrap');
|
|
|
|
|
2015-12-22 07:34:24 -08:00
|
|
|
const Grid = ReactBootstrap.Grid;
|
|
|
|
const Row = ReactBootstrap.Row;
|
|
|
|
const Col = ReactBootstrap.Col;
|
2015-12-22 23:21:33 -08:00
|
|
|
const Nav = ReactBootstrap.Nav;
|
|
|
|
const NavItem = ReactBootstrap.NavItem;
|
|
|
|
const Badge = ReactBootstrap.Badge;
|
2016-03-03 08:51:34 -08:00
|
|
|
const ListGroup = ReactBootstrap.ListGroup;
|
|
|
|
const ListGroupItem = ReactBootstrap.ListGroupItem;
|
2015-12-22 07:34:24 -08:00
|
|
|
|
|
|
|
const electron = require('electron');
|
|
|
|
const remote = electron.remote;
|
|
|
|
|
2015-12-22 22:53:34 -08:00
|
|
|
const osLocale = require('os-locale');
|
|
|
|
const fs = require('fs');
|
|
|
|
const url = require('url');
|
2015-12-23 00:06:17 -08:00
|
|
|
const path = require('path');
|
2015-12-22 22:53:34 -08:00
|
|
|
|
2015-12-22 07:34:24 -08:00
|
|
|
const settings = require('../common/settings');
|
|
|
|
|
2016-01-12 04:28:08 -08:00
|
|
|
remote.getCurrentWindow().removeAllListeners('focus');
|
|
|
|
|
2015-12-22 07:34:24 -08:00
|
|
|
var MainPage = React.createClass({
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2015-12-22 23:21:33 -08:00
|
|
|
key: 0,
|
2016-01-18 17:53:17 -08:00
|
|
|
unreadCounts: new Array(this.props.teams.length),
|
2016-01-23 04:08:05 -08:00
|
|
|
mentionCounts: new Array(this.props.teams.length),
|
2016-01-23 21:31:56 -08:00
|
|
|
unreadAtActive: new Array(this.props.teams.length),
|
2016-02-01 06:58:59 -08:00
|
|
|
mentionAtActiveCounts: new Array(this.props.teams.length)
|
2015-12-22 07:34:24 -08:00
|
|
|
};
|
|
|
|
},
|
2016-01-12 04:28:08 -08:00
|
|
|
componentDidMount: function() {
|
|
|
|
var thisObj = this;
|
2016-01-14 04:51:06 -08:00
|
|
|
var focusListener = function() {
|
2016-01-12 04:28:08 -08:00
|
|
|
var webview = document.getElementById('mattermostView' + thisObj.state.key);
|
|
|
|
webview.focus();
|
2016-01-18 19:43:32 -08:00
|
|
|
|
2016-01-18 20:15:24 -08:00
|
|
|
thisObj.handleOnTeamFocused(thisObj.state.key);
|
2016-01-14 04:51:06 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
var currentWindow = remote.getCurrentWindow();
|
|
|
|
currentWindow.on('focus', focusListener);
|
|
|
|
window.addEventListener('beforeunload', function() {
|
|
|
|
currentWindow.removeListener('focus', focusListener);
|
2016-01-12 04:28:08 -08:00
|
|
|
});
|
|
|
|
},
|
2015-12-22 07:34:24 -08:00
|
|
|
handleSelect: function(key) {
|
|
|
|
this.setState({
|
2015-12-22 23:21:33 -08:00
|
|
|
key: key
|
|
|
|
});
|
2016-01-18 19:43:32 -08:00
|
|
|
this.handleOnTeamFocused(key);
|
2015-12-22 23:21:33 -08:00
|
|
|
},
|
2016-01-25 07:35:59 -08:00
|
|
|
handleUnreadCountChange: function(index, unreadCount, mentionCount, isUnread, isMentioned) {
|
2016-01-18 17:53:17 -08:00
|
|
|
var unreadCounts = this.state.unreadCounts;
|
|
|
|
var mentionCounts = this.state.mentionCounts;
|
2016-01-25 07:35:59 -08:00
|
|
|
var unreadAtActive = this.state.unreadAtActive;
|
2016-02-01 06:58:59 -08:00
|
|
|
var mentionAtActiveCounts = this.state.mentionAtActiveCounts;
|
2016-01-18 17:53:17 -08:00
|
|
|
unreadCounts[index] = unreadCount;
|
|
|
|
mentionCounts[index] = mentionCount;
|
2016-01-25 07:35:59 -08:00
|
|
|
// Never turn on the unreadAtActive flag at current focused tab.
|
|
|
|
if (this.state.key !== index || !remote.getCurrentWindow().isFocused()) {
|
|
|
|
unreadAtActive[index] = unreadAtActive[index] || isUnread;
|
2016-02-01 06:58:59 -08:00
|
|
|
if (isMentioned) {
|
|
|
|
mentionAtActiveCounts[index]++;
|
|
|
|
}
|
2016-01-25 07:35:59 -08:00
|
|
|
}
|
2015-12-22 23:21:33 -08:00
|
|
|
this.setState({
|
2016-01-18 17:53:17 -08:00
|
|
|
unreadCounts: unreadCounts,
|
2016-01-25 07:35:59 -08:00
|
|
|
mentionCounts: mentionCounts,
|
|
|
|
unreadAtActive: unreadAtActive,
|
2016-02-01 06:58:59 -08:00
|
|
|
mentionAtActiveCounts: mentionAtActiveCounts
|
2015-12-22 07:34:24 -08:00
|
|
|
});
|
2016-01-18 19:43:32 -08:00
|
|
|
this.handleUnreadCountTotalChange();
|
|
|
|
},
|
2016-01-25 07:35:59 -08:00
|
|
|
markReadAtActive: function(index) {
|
2016-01-18 19:43:32 -08:00
|
|
|
var unreadAtActive = this.state.unreadAtActive;
|
2016-02-01 06:58:59 -08:00
|
|
|
var mentionAtActiveCounts = this.state.mentionAtActiveCounts;
|
2016-01-25 07:35:59 -08:00
|
|
|
unreadAtActive[index] = false;
|
2016-02-01 06:58:59 -08:00
|
|
|
mentionAtActiveCounts[index] = 0;
|
2016-01-18 19:43:32 -08:00
|
|
|
this.setState({
|
2016-01-23 21:31:56 -08:00
|
|
|
unreadAtActive: unreadAtActive,
|
2016-02-01 06:58:59 -08:00
|
|
|
mentionAtActiveCounts: mentionAtActiveCounts
|
2016-01-18 19:43:32 -08:00
|
|
|
});
|
|
|
|
this.handleUnreadCountTotalChange();
|
|
|
|
},
|
|
|
|
handleUnreadCountTotalChange: function() {
|
2015-12-23 00:06:17 -08:00
|
|
|
if (this.props.onUnreadCountChange) {
|
2016-01-23 04:08:05 -08:00
|
|
|
var allUnreadCount = this.state.unreadCounts.reduce(function(prev, curr) {
|
2015-12-23 00:06:17 -08:00
|
|
|
return prev + curr;
|
2016-01-18 19:43:32 -08:00
|
|
|
}, 0);
|
|
|
|
this.state.unreadAtActive.forEach(function(state) {
|
|
|
|
if (state) {
|
2016-01-23 04:08:05 -08:00
|
|
|
allUnreadCount += 1;
|
2016-01-18 19:43:32 -08:00
|
|
|
}
|
2015-12-23 00:06:17 -08:00
|
|
|
});
|
2016-01-23 04:08:05 -08:00
|
|
|
var allMentionCount = this.state.mentionCounts.reduce(function(prev, curr) {
|
2016-01-18 17:53:17 -08:00
|
|
|
return prev + curr;
|
2016-01-23 04:08:05 -08:00
|
|
|
}, 0);
|
2016-02-01 06:58:59 -08:00
|
|
|
this.state.mentionAtActiveCounts.forEach(function(count) {
|
|
|
|
allMentionCount += count;
|
2016-01-23 21:31:56 -08:00
|
|
|
});
|
2016-01-18 17:53:17 -08:00
|
|
|
this.props.onUnreadCountChange(allUnreadCount, allMentionCount);
|
2015-12-23 00:06:17 -08:00
|
|
|
}
|
2015-12-22 07:34:24 -08:00
|
|
|
},
|
2016-01-18 19:43:32 -08:00
|
|
|
handleOnTeamFocused: function(index) {
|
|
|
|
// Turn off the flag to indicate whether unread message of active channel contains at current tab.
|
2016-01-25 07:35:59 -08:00
|
|
|
this.markReadAtActive(index);
|
2016-01-18 19:43:32 -08:00
|
|
|
},
|
|
|
|
|
2015-12-22 07:34:24 -08:00
|
|
|
visibleStyle: function(visible) {
|
2015-12-23 03:53:54 -08:00
|
|
|
var visibility = visible ? 'visible' : 'hidden';
|
2015-12-22 07:34:24 -08:00
|
|
|
return {
|
|
|
|
position: 'absolute',
|
2016-01-13 05:07:37 -08:00
|
|
|
top: (this.props.teams.length > 1) ? 42 : 0,
|
2015-12-22 07:34:24 -08:00
|
|
|
right: 0,
|
|
|
|
bottom: 0,
|
|
|
|
left: 0,
|
|
|
|
visibility: visibility
|
|
|
|
};
|
|
|
|
},
|
|
|
|
render: function() {
|
2015-12-22 23:21:33 -08:00
|
|
|
var thisObj = this;
|
2016-01-13 05:07:37 -08:00
|
|
|
|
|
|
|
var tabs_row;
|
|
|
|
if (this.props.teams.length > 1) {
|
|
|
|
tabs_row = (
|
|
|
|
<Row>
|
2016-02-01 06:58:59 -08:00
|
|
|
<TabBar id="tabBar" teams={ this.props.teams } unreadCounts={ this.state.unreadCounts } mentionCounts={ this.state.mentionCounts } unreadAtActive={ this.state.unreadAtActive } mentionAtActiveCounts={ this.state.mentionAtActiveCounts }
|
2016-02-11 08:12:28 -08:00
|
|
|
activeKey={ this.state.key } onSelect={ this.handleSelect }></TabBar>
|
2016-01-13 05:07:37 -08:00
|
|
|
</Row>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-12-22 07:34:24 -08:00
|
|
|
var views = this.props.teams.map(function(team, index) {
|
2016-01-25 07:35:59 -08:00
|
|
|
var handleUnreadCountChange = function(unreadCount, mentionCount, isUnread, isMentioned) {
|
|
|
|
thisObj.handleUnreadCountChange(index, unreadCount, mentionCount, isUnread, isMentioned);
|
2016-01-18 19:43:32 -08:00
|
|
|
};
|
2015-12-23 00:16:53 -08:00
|
|
|
var handleNotificationClick = function() {
|
|
|
|
thisObj.handleSelect(index);
|
|
|
|
}
|
2016-02-13 02:30:37 -08:00
|
|
|
return (<MattermostView id={ 'mattermostView' + index } style={ thisObj.visibleStyle(thisObj.state.key === index) } src={ team.url } name={ team.name } onUnreadCountChange={ handleUnreadCountChange } onNotificationClick={ handleNotificationClick }
|
2016-01-25 07:35:59 -08:00
|
|
|
/>)
|
2015-12-22 07:34:24 -08:00
|
|
|
});
|
2016-01-13 05:07:37 -08:00
|
|
|
var views_row = (<Row>
|
|
|
|
{ views }
|
|
|
|
</Row>);
|
2015-12-22 07:34:24 -08:00
|
|
|
return (
|
|
|
|
<Grid fluid>
|
2016-01-13 05:07:37 -08:00
|
|
|
{ tabs_row }
|
|
|
|
{ views_row }
|
2015-12-22 07:34:24 -08:00
|
|
|
</Grid>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-13 05:07:37 -08:00
|
|
|
var TabBar = React.createClass({
|
|
|
|
render: function() {
|
|
|
|
var thisObj = this;
|
|
|
|
var tabs = this.props.teams.map(function(team, index) {
|
2016-01-18 19:43:32 -08:00
|
|
|
var unreadCount = 0;
|
|
|
|
if (thisObj.props.unreadCounts[index] > 0) {
|
|
|
|
unreadCount = thisObj.props.unreadCounts[index];
|
|
|
|
}
|
|
|
|
if (thisObj.props.unreadAtActive[index]) {
|
|
|
|
unreadCount += 1;
|
|
|
|
}
|
2016-01-25 07:35:59 -08:00
|
|
|
|
|
|
|
var mentionCount = 0;
|
|
|
|
if (thisObj.props.mentionCounts[index] > 0) {
|
|
|
|
mentionCount = thisObj.props.mentionCounts[index];
|
|
|
|
}
|
2016-02-01 06:58:59 -08:00
|
|
|
if (thisObj.props.mentionAtActiveCounts[index] > 0) {
|
2016-02-01 08:10:14 -08:00
|
|
|
mentionCount += thisObj.props.mentionAtActiveCounts[index];
|
2016-01-25 07:35:59 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
var badge;
|
|
|
|
if (mentionCount != 0) {
|
2016-01-18 17:53:17 -08:00
|
|
|
badge = (<Badge>
|
2016-01-25 07:35:59 -08:00
|
|
|
{ mentionCount }
|
2016-01-18 17:53:17 -08:00
|
|
|
</Badge>);
|
2016-01-23 04:08:05 -08:00
|
|
|
} else if (unreadCount > 0) {
|
2016-01-13 05:07:37 -08:00
|
|
|
badge = (<Badge>
|
2016-01-21 07:56:17 -08:00
|
|
|
•
|
2016-01-13 05:07:37 -08:00
|
|
|
</Badge>);
|
|
|
|
}
|
|
|
|
return (<NavItem className="teamTabItem" id={ 'teamTabItem' + index } eventKey={ index }>
|
|
|
|
{ team.name }
|
|
|
|
{ ' ' }
|
|
|
|
{ badge }
|
|
|
|
</NavItem>);
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<Nav id={ this.props.id } bsStyle="tabs" activeKey={ this.props.activeKey } onSelect={ this.props.onSelect }>
|
|
|
|
{ tabs }
|
|
|
|
</Nav>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2015-12-22 23:21:33 -08:00
|
|
|
|
2015-12-22 07:34:24 -08:00
|
|
|
var MattermostView = React.createClass({
|
2015-12-22 22:53:34 -08:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2016-03-03 08:51:34 -08:00
|
|
|
did_fail_load: null
|
2015-12-22 22:53:34 -08:00
|
|
|
};
|
|
|
|
},
|
2016-01-25 07:35:59 -08:00
|
|
|
handleUnreadCountChange: function(unreadCount, mentionCount, isUnread, isMentioned) {
|
2015-12-22 22:53:34 -08:00
|
|
|
if (this.props.onUnreadCountChange) {
|
2016-01-25 07:35:59 -08:00
|
|
|
this.props.onUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned);
|
2016-01-18 19:43:32 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-12-22 22:53:34 -08:00
|
|
|
componentDidMount: function() {
|
|
|
|
var thisObj = this;
|
|
|
|
var webview = ReactDOM.findDOMNode(this.refs.webview);
|
|
|
|
|
2016-03-03 08:51:34 -08:00
|
|
|
webview.addEventListener('did-fail-load', function(e) {
|
|
|
|
console.log(thisObj.props.name, 'webview did-fail-load', e);
|
|
|
|
thisObj.setState({
|
|
|
|
did_fail_load: e
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-12-22 22:53:34 -08:00
|
|
|
// Open link in browserWindow. for exmaple, attached files.
|
|
|
|
webview.addEventListener('new-window', function(e) {
|
|
|
|
var currentURL = url.parse(webview.getURL());
|
|
|
|
var destURL = url.parse(e.url);
|
|
|
|
if (currentURL.host === destURL.host) {
|
|
|
|
window.open(e.url, 'electron-mattermost');
|
|
|
|
} else {
|
|
|
|
// if the link is external, use default browser.
|
|
|
|
require('shell').openExternal(e.url);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
webview.addEventListener("dom-ready", function() {
|
|
|
|
// webview.openDevTools();
|
|
|
|
|
|
|
|
// Use 'Meiryo UI' and 'MS Gothic' to prevent CJK fonts on Windows(JP).
|
|
|
|
if (process.platform === 'win32') {
|
|
|
|
var applyCssFile = function(cssFile) {
|
|
|
|
fs.readFile(cssFile, 'utf8', function(err, data) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
webview.insertCSS(data);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
osLocale(function(err, locale) {
|
|
|
|
if (err) {
|
|
|
|
console.log(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (locale === 'ja_JP') {
|
|
|
|
applyCssFile(__dirname + '/css/jp_fonts.css');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
webview.addEventListener('ipc-message', function(event) {
|
|
|
|
switch (event.channel) {
|
|
|
|
case 'onUnreadCountChange':
|
|
|
|
var unreadCount = event.args[0];
|
2016-01-18 17:53:17 -08:00
|
|
|
var mentionCount = event.args[1];
|
2016-01-25 07:35:59 -08:00
|
|
|
// isUnread and isMentioned is pulse flag.
|
|
|
|
var isUnread = event.args[2];
|
|
|
|
var isMentioned = event.args[3];
|
|
|
|
thisObj.handleUnreadCountChange(unreadCount, mentionCount, isUnread, isMentioned);
|
2015-12-22 22:53:34 -08:00
|
|
|
break;
|
2015-12-23 00:16:53 -08:00
|
|
|
case 'onNotificationClick':
|
|
|
|
thisObj.props.onNotificationClick();
|
2016-01-18 17:53:17 -08:00
|
|
|
break;
|
2015-12-22 22:53:34 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-02-13 02:30:37 -08:00
|
|
|
webview.addEventListener('console-message', (e) => {
|
2016-02-13 02:30:37 -08:00
|
|
|
const message = `[${this.props.name}] ${e.message}`;
|
|
|
|
switch (e.level) {
|
|
|
|
case 0:
|
|
|
|
console.log(message);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
console.warn(message);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
console.error(message);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log(message);
|
|
|
|
break;
|
|
|
|
}
|
2016-02-13 02:30:37 -08:00
|
|
|
});
|
2015-12-22 22:53:34 -08:00
|
|
|
},
|
2015-12-22 07:34:24 -08:00
|
|
|
render: function() {
|
|
|
|
// 'disablewebsecurity' is necessary to display external images.
|
|
|
|
// However, it allows also CSS/JavaScript.
|
|
|
|
// So webview should use 'allowDisplayingInsecureContent' as same as BrowserWindow.
|
2016-03-03 08:51:34 -08:00
|
|
|
if (this.state.did_fail_load === null) {
|
|
|
|
return (<webview id={ this.props.id } className="mattermostView" style={ this.props.style } preload="webview/mattermost.js" src={ this.props.src } ref="webview"></webview>);
|
|
|
|
} else {
|
|
|
|
return (<ErrorView errorInfo={ this.state.did_fail_load } style={ this.props.style }></ErrorView>)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// ErrorCode: https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h
|
2016-03-05 03:26:13 -08:00
|
|
|
// FIXME: need better wording in English
|
2016-03-03 08:51:34 -08:00
|
|
|
var ErrorView = React.createClass({
|
|
|
|
render: function() {
|
|
|
|
return (
|
|
|
|
<Grid fluid style={ this.props.style }>
|
|
|
|
<h1>Failed to load the URL</h1>
|
|
|
|
<p>
|
|
|
|
{ 'URL: ' }
|
|
|
|
{ this.props.errorInfo.validatedURL }
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
{ 'Error code: ' }
|
|
|
|
{ this.props.errorInfo.errorCode }
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
{ this.props.errorInfo.errorDescription }
|
|
|
|
</p>
|
2016-03-05 03:26:13 -08:00
|
|
|
<p>Please check below. Then, reload this window. (Ctrl+R or Command+R)</p>
|
2016-03-03 08:51:34 -08:00
|
|
|
<ListGroup>
|
|
|
|
<ListGroupItem>Is your computer online?</ListGroupItem>
|
|
|
|
<ListGroupItem>Is the server alive?</ListGroupItem>
|
|
|
|
<ListGroupItem>Is the URL correct?</ListGroupItem>
|
|
|
|
</ListGroup>
|
|
|
|
</Grid>
|
|
|
|
);
|
2015-12-22 07:34:24 -08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-23 02:25:14 -08:00
|
|
|
var config;
|
|
|
|
try {
|
|
|
|
var configFile = remote.getGlobal('config-file');
|
|
|
|
config = settings.readFileSync(configFile);
|
|
|
|
} catch (e) {
|
|
|
|
window.location = 'settings.html';
|
|
|
|
}
|
2016-01-14 06:27:37 -08:00
|
|
|
if (config.teams.length === 0) {
|
|
|
|
window.location = 'settings.html';
|
|
|
|
}
|
2015-12-22 07:34:24 -08:00
|
|
|
|
2015-12-23 00:55:39 -08:00
|
|
|
var contextMenu = require('./menus/context');
|
|
|
|
var menu = contextMenu.createDefault();
|
|
|
|
window.addEventListener('contextmenu', function(e) {
|
|
|
|
menu.popup(remote.getCurrentWindow());
|
|
|
|
}, false);
|
|
|
|
|
2016-02-11 07:44:16 -08:00
|
|
|
var showUnreadBadgeWindows = function(unreadCount, mentionCount) {
|
|
|
|
const badge = require('./js/badge');
|
|
|
|
const sendBadge = function(dataURL, description) {
|
|
|
|
// window.setOverlayIcon() does't work with NativeImage across remote boundaries.
|
|
|
|
// https://github.com/atom/electron/issues/4011
|
|
|
|
electron.ipcRenderer.send('win32-overlay', {
|
|
|
|
overlayDataURL: dataURL,
|
2016-02-25 05:21:28 -08:00
|
|
|
description: description,
|
|
|
|
unreadCount: unreadCount,
|
|
|
|
mentionCount: mentionCount
|
2016-02-11 07:44:16 -08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
if (mentionCount > 0) {
|
|
|
|
const dataURL = badge.createDataURL(mentionCount.toString());
|
|
|
|
sendBadge(dataURL, 'You have unread mention (' + mentionCount + ')');
|
|
|
|
} else if (unreadCount > 0) {
|
|
|
|
const dataURL = badge.createDataURL('•');
|
|
|
|
sendBadge(dataURL, 'You have unread channels');
|
|
|
|
} else {
|
2016-02-25 05:21:28 -08:00
|
|
|
sendBadge(null, 'You have no unread messages');
|
2016-02-11 07:44:16 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var showUnreadBadgeOSX = function(unreadCount, mentionCount) {
|
|
|
|
if (mentionCount > 0) {
|
|
|
|
remote.app.dock.setBadge(mentionCount.toString());
|
|
|
|
} else if (unreadCount > 0) {
|
|
|
|
remote.app.dock.setBadge('•');
|
|
|
|
} else {
|
|
|
|
remote.app.dock.setBadge('');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-18 17:53:17 -08:00
|
|
|
var showUnreadBadge = function(unreadCount, mentionCount) {
|
2015-12-23 00:06:17 -08:00
|
|
|
switch (process.platform) {
|
|
|
|
case 'win32':
|
2016-02-11 07:44:16 -08:00
|
|
|
showUnreadBadgeWindows(unreadCount, mentionCount);
|
2015-12-23 00:06:17 -08:00
|
|
|
break;
|
|
|
|
case 'darwin':
|
2016-02-11 07:44:16 -08:00
|
|
|
showUnreadBadgeOSX(unreadCount, mentionCount);
|
2015-12-23 00:06:17 -08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-22 07:34:24 -08:00
|
|
|
ReactDOM.render(
|
2015-12-23 00:06:17 -08:00
|
|
|
<MainPage teams={ config.teams } onUnreadCountChange={ showUnreadBadge } />,
|
2015-12-22 07:34:24 -08:00
|
|
|
document.getElementById('content')
|
|
|
|
);
|