Refactored post handling/updating on both the client and server.
Этот коммит содержится в:
@@ -5,63 +5,83 @@
|
||||
to the server on page load. This is to prevent other React controls from spamming
|
||||
AsyncClient with requests. */
|
||||
|
||||
var BrowserStore = require('../stores/browser_store.jsx');
|
||||
var AsyncClient = require('../utils/async_client.jsx');
|
||||
var SocketStore = require('../stores/socket_store.jsx');
|
||||
var ChannelStore = require('../stores/channel_store.jsx');
|
||||
var PostStore = require('../stores/post_store.jsx');
|
||||
var UserStore = require('../stores/user_store.jsx');
|
||||
var Constants = require('../utils/constants.jsx');
|
||||
|
||||
var utils = require('../utils/utils.jsx');
|
||||
|
||||
module.exports = React.createClass({
|
||||
componentDidMount: function() {
|
||||
|
||||
/* Start initial aysnc loads */
|
||||
/* Initial aysnc loads */
|
||||
AsyncClient.getMe();
|
||||
AsyncClient.getPosts(true, ChannelStore.getCurrentId(), Constants.POST_CHUNK_SIZE);
|
||||
AsyncClient.getPosts(ChannelStore.getCurrentId());
|
||||
AsyncClient.getChannels(true, true);
|
||||
AsyncClient.getChannelExtraInfo(true);
|
||||
AsyncClient.findTeams();
|
||||
AsyncClient.getStatuses();
|
||||
AsyncClient.getMyTeam();
|
||||
/* End of async loads */
|
||||
|
||||
/* Perform pending post clean-up */
|
||||
PostStore.clearPendingPosts();
|
||||
/* End pending post clean-up */
|
||||
|
||||
/* Start interval functions */
|
||||
/* Set up interval functions */
|
||||
setInterval(
|
||||
function pollStatuses() {
|
||||
AsyncClient.getStatuses();
|
||||
}, 30000);
|
||||
/* End interval functions */
|
||||
|
||||
/* Start device tracking setup */
|
||||
/* Device tracking setup */
|
||||
var iOS = (/(iPad|iPhone|iPod)/g).test(navigator.userAgent);
|
||||
if (iOS) {
|
||||
$('body').addClass('ios');
|
||||
}
|
||||
/* End device tracking setup */
|
||||
|
||||
/* Start window active tracking setup */
|
||||
/* Set up tracking for whether the window is active */
|
||||
window.isActive = true;
|
||||
|
||||
$(window).focus(function() {
|
||||
$(window).focus(function windowFocus() {
|
||||
AsyncClient.updateLastViewedAt();
|
||||
window.isActive = true;
|
||||
});
|
||||
|
||||
$(window).blur(function() {
|
||||
$(window).blur(function windowBlur() {
|
||||
window.isActive = false;
|
||||
});
|
||||
/* End window active tracking setup */
|
||||
|
||||
/* Start global change listeners setup */
|
||||
SocketStore.addChangeListener(this._onSocketChange);
|
||||
/* End global change listeners setup */
|
||||
SocketStore.addChangeListener(this.onSocketChange);
|
||||
|
||||
/* Update CSS classes to match user theme */
|
||||
var user = UserStore.getCurrentUser();
|
||||
|
||||
if (user.props && user.props.theme) {
|
||||
utils.changeCss('div.theme', 'background-color:' + user.props.theme + ';');
|
||||
utils.changeCss('.btn.btn-primary', 'background: ' + user.props.theme + ';');
|
||||
utils.changeCss('.modal .modal-header', 'background: ' + user.props.theme + ';');
|
||||
utils.changeCss('.mention', 'background: ' + user.props.theme + ';');
|
||||
utils.changeCss('.mention-link', 'color: ' + user.props.theme + ';');
|
||||
utils.changeCss('@media(max-width: 768px){.search-bar__container', 'background: ' + user.props.theme + ';}');
|
||||
utils.changeCss('.search-item-container:hover', 'background: ' + utils.changeOpacity(user.props.theme, 0.05) + ';');
|
||||
}
|
||||
|
||||
if (user.props.theme !== '#000000' && user.props.theme !== '#585858') {
|
||||
utils.changeCss('.btn.btn-primary:hover, .btn.btn-primary:active, .btn.btn-primary:focus', 'background: ' + utils.changeColor(user.props.theme, -10) + ';');
|
||||
utils.changeCss('a.theme', 'color:' + user.props.theme + '; fill:' + user.props.theme + '!important;');
|
||||
} else if (user.props.theme === '#000000') {
|
||||
utils.changeCss('.btn.btn-primary:hover, .btn.btn-primary:active, .btn.btn-primary:focus', 'background: ' + utils.changeColor(user.props.theme, +50) + ';');
|
||||
$('.team__header').addClass('theme--black');
|
||||
} else if (user.props.theme === '#585858') {
|
||||
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');
|
||||
}
|
||||
},
|
||||
_onSocketChange: function(msg) {
|
||||
if (msg && msg.user_id) {
|
||||
onSocketChange: function(msg) {
|
||||
if (msg && msg.user_id && msg.user_id !== UserStore.getCurrentId()) {
|
||||
UserStore.setStatus(msg.user_id, 'online');
|
||||
}
|
||||
},
|
||||
|
||||
Ссылка в новой задаче
Block a user