subscriptions lastActivity

pull/7748/head
Guilherme Gazzo 8 years ago
parent 2580b0350a
commit 52b43d6a1f
No known key found for this signature in database
GPG Key ID: 1F85C9AD922D0829
  1. 2
      packages/rocketchat-lib/server/lib/notifyUsersOnMessage.js
  2. 25
      packages/rocketchat-lib/server/models/Subscriptions.js
  3. 12
      packages/rocketchat-theme/client/imports/general/base_old.css
  4. 4
      packages/rocketchat-ui-sidenav/client/roomList.js
  5. 1
      server/publications/room.js
  6. 1
      server/publications/subscription.js
  7. 14
      server/startup/migrations/v099.js

@ -84,6 +84,8 @@ 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;

@ -402,23 +402,32 @@ 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,
'u._id': {
$ne: userId
},
$or: [
{ alert: { $ne: true } },
{ open: { $ne: true } }
]
}
};
// TODO: test if is already open or alert when we find a best solution to update the last message on subscription
const update = {
$set: {
alert: true,
open: true
open: true,
lastActivity: new Date
}
};

@ -1558,12 +1558,12 @@
/* MAIN CONTENT + MAIN PAGES */
.rc-old.main-content {
top: 0;
bottom: 0;
left: var(--rooms-box-width);
right: 0;
width: auto;
height: auto;
/*top: 0;
bottom: 0;*/
/*left: var(--rooms-box-width);*/
/*right: 0;*/
/*width: auto;*/
/*height: auto;*/
&.main-modal {
left: 0;

@ -1,6 +1,6 @@
Template.roomList.helpers({
rooms() {
if (this.identifier == 'unread') {
if (this.identifier === 'unread') {
const query = {
alert: true,
open: true,
@ -26,7 +26,7 @@ Template.roomList.helpers({
let types = [this.identifier];
if (this.identifier === 'activity') {
types = ['c', 'p', 'd'];
sort = { _updatedAt : -1};
sort = { lastActivity : -1, _updatedAt: -1};
}
if (this.identifier === 'channels' || this.identifier === 'unread') {
types= [ 'c', 'p'];

@ -20,6 +20,7 @@ const options = {
sms: 1,
code: 1,
open: 1,
lastActivity: 1,
v: 1,
label: 1,
ro: 1,

@ -8,6 +8,7 @@ const fields = {
code: 1,
f: 1,
u: 1,
lastActivity: 1,
open: 1,
alert: 1,
roles: 1,

@ -0,0 +1,14 @@
RocketChat.Migrations.add({
version: 99,
up() {
return RocketChat.models.Subscriptions.find({ lastActivity: {$exists: false} }).forEach(item => {
return RocketChat.models.Subscriptions.update({
rid: item.rid
}, {
$set: {
lastActivity: item.ls
}
});
});
}
});
Loading…
Cancel
Save