summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/channel.go4
-rw-r--r--model/message.go1
-rw-r--r--store/sql_user_store.go5
-rw-r--r--webapp/action_creators/websocket_actions.jsx10
-rw-r--r--webapp/components/sidebar.jsx20
-rw-r--r--webapp/stores/user_store.jsx10
-rw-r--r--webapp/utils/constants.jsx1
7 files changed, 47 insertions, 4 deletions
diff --git a/api/channel.go b/api/channel.go
index 7cfc22833..b63e44017 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -152,6 +152,10 @@ func CreateDirectChannel(userId string, otherUserId string) (*model.Channel, *mo
return nil, result.Err
}
} else {
+ message := model.NewMessage("", channel.Id, userId, model.ACTION_DIRECT_ADDED)
+ message.Add("teammate_id", otherUserId)
+ PublishAndForget(message)
+
return result.Data.(*model.Channel), nil
}
}
diff --git a/model/message.go b/model/message.go
index 53ce4c154..a986af4de 100644
--- a/model/message.go
+++ b/model/message.go
@@ -15,6 +15,7 @@ const (
ACTION_POST_DELETED = "post_deleted"
ACTION_CHANNEL_DELETED = "channel_deleted"
ACTION_CHANNEL_VIEWED = "channel_viewed"
+ ACTION_DIRECT_ADDED = "direct_added"
ACTION_NEW_USER = "new_user"
ACTION_USER_ADDED = "user_added"
ACTION_USER_REMOVED = "user_removed"
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 8d4f1a31b..974081a64 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -434,7 +434,7 @@ func (s SqlUserStore) GetEtagForDirectProfiles(userId string) StoreChannel {
result := StoreResult{}
updateAt, err := s.GetReplica().SelectInt(`
- SELECT
+ SELECT
UpdateAt
FROM
Users
@@ -454,13 +454,14 @@ func (s SqlUserStore) GetEtagForDirectProfiles(userId string) StoreChannel {
Channels.Type = 'D'
AND Channels.Id = ChannelMembers.ChannelId
AND ChannelMembers.UserId = :UserId))
- OR Id IN (SELECT
+ OR Id IN (SELECT
Name
FROM
Preferences
WHERE
UserId = :UserId
AND Category = 'direct_channel_show')
+ ORDER BY UpdateAt DESC
`, map[string]interface{}{"UserId": userId})
if err != nil {
result.Data = fmt.Sprintf("%v.%v", model.CurrentVersion, model.GetMillis())
diff --git a/webapp/action_creators/websocket_actions.jsx b/webapp/action_creators/websocket_actions.jsx
index 0d4c76201..b208b4d33 100644
--- a/webapp/action_creators/websocket_actions.jsx
+++ b/webapp/action_creators/websocket_actions.jsx
@@ -141,6 +141,10 @@ function handleMessage(msg) {
handleChannelDeletedEvent(msg);
break;
+ case SocketEvents.DIRECT_ADDED:
+ handleDirectAddedEvent(msg);
+ break;
+
case SocketEvents.PREFERENCE_CHANGED:
handlePreferenceChangedEvent(msg);
break;
@@ -201,9 +205,15 @@ function handlePostDeleteEvent(msg) {
function handleNewUserEvent() {
AsyncClient.getProfiles();
+ AsyncClient.getDirectProfiles();
AsyncClient.getChannelExtraInfo();
}
+function handleDirectAddedEvent(msg) {
+ AsyncClient.getChannel(msg.channel_id);
+ AsyncClient.getDirectProfiles();
+}
+
function handleUserAddedEvent(msg) {
if (ChannelStore.getCurrentId() === msg.channel_id) {
AsyncClient.getChannelExtraInfo();
diff --git a/webapp/components/sidebar.jsx b/webapp/components/sidebar.jsx
index 71091f12b..29ad60acc 100644
--- a/webapp/components/sidebar.jsx
+++ b/webapp/components/sidebar.jsx
@@ -91,6 +91,7 @@ export default class Sidebar extends React.Component {
const preferences = PreferenceStore.getCategory(Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW);
const directChannels = [];
+ const directNonTeamChannels = [];
for (const [name, value] of preferences) {
if (value !== 'true') {
continue;
@@ -117,10 +118,15 @@ export default class Sidebar extends React.Component {
directChannel.teammate_id = teammateId;
directChannel.status = UserStore.getStatus(teammateId);
- directChannels.push(directChannel);
+ if (UserStore.hasTeamProfile(teammateId)) {
+ directChannels.push(directChannel);
+ } else {
+ directNonTeamChannels.push(directChannel);
+ }
}
directChannels.sort(this.sortChannelsByDisplayName);
+ directNonTeamChannels.sort(this.sortChannelsByDisplayName);
const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999);
@@ -130,6 +136,7 @@ export default class Sidebar extends React.Component {
publicChannels,
privateChannels,
directChannels,
+ directNonTeamChannels,
unreadCounts: JSON.parse(JSON.stringify(ChannelStore.getUnreadCounts())),
showTutorialTip: tutorialStep === TutorialSteps.CHANNEL_POPOVER,
currentTeam: TeamStore.getCurrent(),
@@ -496,6 +503,15 @@ export default class Sidebar extends React.Component {
return this.createChannelElement(channel, index, arr, this.handleLeaveDirectChannel);
});
+ const directMessageNonTeamItems = this.state.directNonTeamChannels.map((channel, index, arr) => {
+ return this.createChannelElement(channel, index, arr, this.handleLeaveDirectChannel);
+ });
+
+ let directDivider;
+ if (directMessageNonTeamItems.length !== 0) {
+ directDivider = <hr/>;
+ }
+
// update the favicon to show if there are any notifications
if (this.lastBadgesActive !== this.badgesActive) {
var link = document.createElement('link');
@@ -675,6 +691,8 @@ export default class Sidebar extends React.Component {
</h4>
</li>
{directMessageItems}
+ {directDivider}
+ {directMessageNonTeamItems}
{directMessageMore}
</ul>
</div>
diff --git a/webapp/stores/user_store.jsx b/webapp/stores/user_store.jsx
index 2d792fa17..8ae1e1404 100644
--- a/webapp/stores/user_store.jsx
+++ b/webapp/stores/user_store.jsx
@@ -114,6 +114,14 @@ class UserStoreClass extends EventEmitter {
return this.getProfile(userId) != null;
}
+ hasTeamProfile(userId) {
+ return this.getProfiles()[userId];
+ }
+
+ hasDirectProfile(userId) {
+ return this.getDirectProfiles()[userId];
+ }
+
getProfile(userId) {
if (userId === this.getCurrentId()) {
return this.getCurrentUser();
@@ -194,7 +202,7 @@ class UserStoreClass extends EventEmitter {
const currentUser = this.profiles[currentId];
if (currentUser) {
if (currentId in this.profiles) {
- delete this.profiles[currentId];
+ Reflect.deleteProperty(this.profiles, currentId);
}
this.profiles = profiles;
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index fb4086c7a..a505812f3 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -151,6 +151,7 @@ export default {
POST_DELETED: 'post_deleted',
CHANNEL_DELETED: 'channel_deleted',
CHANNEL_VIEWED: 'channel_viewed',
+ DIRECT_ADDED: 'direct_added',
NEW_USER: 'new_user',
USER_ADDED: 'user_added',
USER_REMOVED: 'user_removed',