This commit is contained in:
Asaad Mahmood
2015-07-10 20:24:18 +05:00
10 changed files with 60 additions and 8 deletions

View File

@@ -655,6 +655,10 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
c.LogAudit("name=" + channel.Name + " user_id=" + userId)
message := model.NewMessage(c.Session.TeamId, "", userId, model.ACTION_USER_ADDED)
store.PublishAndForget(message)
<-Srv.Store.Channel().UpdateLastViewedAt(id, oUser.Id)
w.Write([]byte(cm.ToJson()))
}

View File

@@ -15,6 +15,7 @@ const (
ACTION_POST_DELETED = "post_deleted"
ACTION_VIEWED = "viewed"
ACTION_NEW_USER = "new_user"
ACTION_USER_ADDED = "user_added"
)
type Message struct {

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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() {

View File

@@ -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()) {

View File

@@ -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;
}
}
};

View File

@@ -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);
}

View File

@@ -0,0 +1,13 @@
{
"name": "Mattermost",
"icons": [
{
"src": "../static/iamges/icon50x50.gif",
"sizes": "50x50",
"type": "image/png"
}
],
"start_url": "/",
"display": "standalone",
"orientation": "portrait"
}

View File

@@ -5,6 +5,19 @@
<title>{{ .Title }}</title>
<!-- iOS add to homescreen -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="{{ .Title }}">
<meta name="application-name" content="{{ .Title }}">
<meta name="format-detection" content="telephone=no">
<!-- iOS add to homescreen -->
<!-- Android add to homescreen -->
<link rel="manifest" href="/static/config/manifest.json">
<!-- Android add to homescreen -->
<link rel="stylesheet" href="/static/css/bootstrap-3.3.1.min.css">
<link rel="stylesheet" href="/static/css/jasny-bootstrap.min.css" rel="stylesheet">