Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove field lastActivity from subscription data #8345

Merged
merged 2 commits into from
Sep 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
// Update all other subscriptions to alert their owners but witout incrementing
// the unread counter, as it is only for mentions and direct messages
RocketChat.models.Subscriptions.setAlertForRoomIdExcludingUserId(message.rid, message.u._id);
// Used to order subscriptions by activity
RocketChat.models.Subscriptions.updateUserSubscription(message.rid, message.u._id);

return message;

Expand Down
13 changes: 0 additions & 13 deletions packages/rocketchat-lib/server/models/Subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,19 +416,6 @@ class ModelSubscriptions extends RocketChat.models._Base {

return this.update(query, update, { multi: true });
}
updateUserSubscription(rid, userId) {
const query = {
rid,
'u._id': userId
};
const update = {
$set: {
open: true,
lastActivity: new Date
}
};
return this.update(query, update);
}
setAlertForRoomIdExcludingUserId(roomId, userId) {
const query = {
rid: roomId,
Expand Down
8 changes: 3 additions & 5 deletions packages/rocketchat-ui-sidenav/client/roomList.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ Template.roomList.helpers({
const query = {
open: true
};
let sort = { 't': 1, 'name': 1 };
const sort = { 't': 1, 'name': 1 };
if (this.identifier === 'f') {
query.f = favoritesEnabled;
} else {
let types = [this.identifier];
if (this.identifier === 'activity') {
types = ['c', 'p', 'd'];
sort = { lastActivity : -1, _updatedAt: -1};
Copy link
Member

Choose a reason for hiding this comment

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

according to this it should still sort by _updatedAt

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @sampaiodiego

Copy link
Member Author

Choose a reason for hiding this comment

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

@sampaiodiego @engelgabriel sort is not used if the indentifier === "activity"

}
if (this.identifier === 'channels' || this.identifier === 'unread') {
types= [ 'c', 'p'];
types = [ 'c', 'p'];
}
const user = Meteor.user();
if (user && user.settings && user.settings.preferences && user.settings.preferences.roomsListExhibitionMode === 'unread') {
Expand All @@ -50,9 +49,8 @@ Template.roomList.helpers({
};
});
return _.sortBy(list, 'lm').reverse();
} else {
return ChatSubscription.find(query, { sort });
}
return ChatSubscription.find(query, { sort });
},

isLivechat() {
Expand Down
1 change: 0 additions & 1 deletion server/publications/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const options = {
sms: 1,
code: 1,
open: 1,
lastActivity: 1,
v: 1,
label: 1,
ro: 1,
Expand Down
1 change: 0 additions & 1 deletion server/publications/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const fields = {
code: 1,
f: 1,
u: 1,
lastActivity: 1,
open: 1,
alert: 1,
roles: 1,
Expand Down
6 changes: 6 additions & 0 deletions server/startup/migrations/v101.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RocketChat.Migrations.add({
version: 101,
up() {
RocketChat.models.Subscriptions.update({lastActivity:{$exists:1}}, { $unset: { 'lastActivity': '' } }, {multi: true});
}
});