Этот коммит содержится в:
Asaad Mahmood
2015-07-10 20:24:18 +05:00
родитель 53d0420e24 ff128d7c16
Коммит 14395689ca
10 изменённых файлов: 60 добавлений и 8 удалений

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

@@ -12,8 +12,6 @@ var Constants = require('../utils/constants.jsx');
module.exports = React.createClass({
componentDidMount: function() {
// Initalize stores
BrowserStore.initalize();
/* Start initial aysnc loads */
AsyncClient.getMe();

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

@@ -78,6 +78,7 @@ module.exports = React.createClass({
PostStore.addChangeListener(this._onChange);
ChannelStore.addChangeListener(this._onChange);
UserStore.addStatusesChangeListener(this._onChange);
SocketStore.addChangeListener(this._onSocketChange);
$(".post-list-holder-by-time").perfectScrollbar();
@@ -157,6 +158,7 @@ module.exports = React.createClass({
componentWillUnmount: function() {
PostStore.removeChangeListener(this._onChange);
ChannelStore.removeChangeListener(this._onChange);
UserStore.removeStatusesChangeListener(this._onChange);
SocketStore.removeChangeListener(this._onSocketChange);
$('body').off('click.userpopover');
},
@@ -193,6 +195,9 @@ module.exports = React.createClass({
this.scrolledToNew = false;
}
this.setState(newState);
} else {
// Updates the timestamp on each post
this.forceUpdate()
}
},
_onSocketChange: function(msg) {

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

@@ -263,6 +263,10 @@ var SidebarLoggedIn = React.createClass({
if (ChannelStore.getCurrentId() != msg.channel_id) {
AsyncClient.getChannels(true);
}
} else if (msg.action == "user_added") {
if (UserStore.getCurrentId() === msg.user_id) {
AsyncClient.getChannels(true);
}
}
},
updateTitle: function() {

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

@@ -16,10 +16,16 @@ module.exports = React.createClass({
componentDidMount: function() {
PostStore.addSearchChangeListener(this._onSearchChange);
PostStore.addSelectedPostChangeListener(this._onSelectedChange);
UserStore.addStatusesChangeListener(this._onChange);
},
componentWillUnmount: function() {
PostStore.removeSearchChangeListener(this._onSearchChange);
PostStore.removeSelectedPostChangeListener(this._onSelectedChange);
UserStore.removeStatusesChangeListener(this._onChange);
},
_onChange: function() {
// Updates the timestamp on each post
this.forceUpdate();
},
_onSelectedChange: function(from_search) {
if (this.isMounted()) {

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

@@ -1,44 +1,52 @@
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
var UserStore = require('../stores/user_store.jsx');
// Also change model/utils.go ETAG_ROOT_VERSION
var BROWSER_STORE_VERSION = '.1';
module.exports.initalize = function() {
var _initialized = false;
function _initialize() {
var currentVersion = localStorage.getItem("local_storage_version");
if (currentVersion !== BROWSER_STORE_VERSION) {
localStorage.clear();
sessionStorage.clear();
localStorage.setItem("local_storage_version", BROWSER_STORE_VERSION);
}
_initialized = true;
}
module.exports.setItem = function(name, value) {
if (!_initialized) _initialize();
var user_id = UserStore.getCurrentId();
localStorage.setItem(user_id + "_" + name, value);
};
module.exports.getItem = function(name) {
if (!_initialized) _initialize();
var user_id = UserStore.getCurrentId();
return localStorage.getItem(user_id + "_" + name);
};
module.exports.removeItem = function(name) {
if (!_initialized) _initialize();
var user_id = UserStore.getCurrentId();
localStorage.removeItem(user_id + "_" + name);
};
module.exports.setGlobalItem = function(name, value) {
if (!_initialized) _initialize();
localStorage.setItem(name, value);
};
module.exports.getGlobalItem = function(name) {
if (!_initialized) _initialize();
return localStorage.getItem(name);
};
module.exports.removeGlobalItem = function(name) {
if (!_initialized) _initialize();
localStorage.removeItem(name);
};
@@ -53,7 +61,7 @@ module.exports.actionOnItemsWithPrefix = function (prefix, action) {
var user_id = UserStore.getCurrentId();
var id_len = user_id.length;
var prefix_len = prefix.length;
for (key in localStorage) {
for (var key in localStorage) {
if (key.substring(id_len, id_len + prefix_len) === prefix) {
var userkey = key.substring(id_len);
action(userkey, BrowserStore.getItem(key));
@@ -70,8 +78,8 @@ module.exports.isLocalStorageSupported = function() {
localStorage.removeItem("testLocal", '1');
return true;
}
}
catch (e) {
return false;
}
}
};

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

@@ -55,7 +55,7 @@ module.exports.getChannels = function(force, updateLastViewed, checkVersion) {
if (checkVersion) {
var serverVersion = xhr.getResponseHeader("X-Version-ID");
if (UserStore.getLastVersion() == undefined) {
if (!UserStore.getLastVersion()) {
UserStore.setLastVersion(serverVersion);
}