Skip to content

[NEW] Add option to user show hidden rooms when unread messages#8053

Closed
lindoelio wants to merge 10 commits intoRocketChat:developfrom
lindoelio:increment-for-rooms-visibility-control
Closed

[NEW] Add option to user show hidden rooms when unread messages#8053
lindoelio wants to merge 10 commits intoRocketChat:developfrom
lindoelio:increment-for-rooms-visibility-control

Conversation

@lindoelio
Copy link
Contributor

@RocketChat/core

Closes #6299

Extend implements of PR #6299 for hit the suggestions about user's control over "show hidden rooms when unread messages".

image

@RocketChat RocketChat deleted a comment Sep 6, 2017
@engelgabriel engelgabriel added this to the 0.60.0 milestone Sep 6, 2017
@lindoelio lindoelio changed the title [NEW] Add option to user preferences for show hidden rooms when unread mess… [NEW] Add option to user show hidden rooms when unread messages Oct 25, 2017
// the unread counter, as it is only for mentions and direct messages
RocketChat.models.Subscriptions.setAlertForRoomIdExcludingUserId(message.rid, message.u._id);
const subscriptions = RocketChat.models.Subscriptions.findByRoomIdForAlert(message.rid);
if (subscriptions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subscriptions will be the cursor, so it will always exists

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

let userSubscribed = {};
let showHiddenRoom;
subscriptions.forEach(function(subscription) {
if (subscription.u._id !== message.u._id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't want to process the sender, you could pass that to query and not retrieve the record

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

let showHiddenRoom;
subscriptions.forEach(function(subscription) {
if (subscription.u._id !== message.u._id) {
userSubscribed = RocketChat.models.Users.findById(message.u._id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that correct? Get the message user and not the subscription user?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findById is a find, so it returns a cursor, not one record, did you tested this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

if (subscription.u._id !== message.u._id) {
userSubscribed = RocketChat.models.Users.findById(message.u._id);
showHiddenRoom = userSubscribed && userSubscribed.settings && userSubscribed.settings.preferences && userSubscribed.settings.preferences.showHiddenRoomsWhenUnreadMessages;
RocketChat.models.Subscriptions.setAlertForUserSubscribed(subscription.u._id, showHiddenRoom);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here is to set everyone to alert at line 109 and then set again here to alert true/false depending on each user preference?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when showHiddenRoom is undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to set everyone to alert, but open room only for one want this behavior. Fixed.

}

// Used to order subscriptions by activity
RocketChat.models.Subscriptions.updateUserSubscription(message.rid, message.u._id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that for?

@rodrigok rodrigok modified the milestones: 0.60.0, 0.61.0 Dec 8, 2017
@RocketChat RocketChat deleted a comment from CLAassistant Dec 16, 2017
@RocketChat RocketChat deleted a comment from CLAassistant Dec 16, 2017
@RocketChat RocketChat deleted a comment from CLAassistant Dec 26, 2017
@rodrigok rodrigok modified the milestones: 0.61.0, 0.61.1 Jan 22, 2018
@rodrigok rodrigok modified the milestones: 0.61.1, 0.63.0 Feb 13, 2018
@engelgabriel engelgabriel modified the milestones: 0.63.0, 0.65.0 May 5, 2018
@theorenck theorenck modified the milestones: 0.65.0, Short-term Jul 31, 2018
@Hudell
Copy link
Contributor

Hudell commented May 15, 2019

I'll be closing this because the option to keep the rooms hidden will not be merged.

@Hudell Hudell closed this May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Comments