mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Add separator between DMs on your team and not (#2910)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user