Group DM improvements

pull/16569/head^2
Diego Sampaio 6 years ago
parent 2d4e5ca4a6
commit 0cf6dbd2b6
No known key found for this signature in database
GPG Key ID: E060152B30502562
  1. 3
      app/ui/client/views/app/CreateDirectMessage.js
  2. 19
      server/startup/migrations/v179.js

@ -1,6 +1,7 @@
import { Tracker } from 'meteor/tracker';
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { roomTypes } from '../../../../utils/client';
import { call } from '../../../../ui-utils/client';
@ -83,6 +84,8 @@ Template.CreateDirectMessage.onRendered(function() {
});
Template.CreateDirectMessage.onCreated(function() {
this.selectedUsers = new ReactiveVar([]);
this.onSelectUser = ({ item: user }) => {
if (user.username === Meteor.user().username) {
return;

@ -41,13 +41,22 @@ async function migrateDMs(models, total, current) {
const items = await roomCollection.find({ t: 'd', uids: { $exists: false } }, { fields: { _id: 1 } }).limit(batchSize).toArray();
const actions = items.map((room) => roomCollection.updateOne({ _id: room._id }, {
$set: {
uids: getIds(room._id),
const actions = items.map((room) => ({
updateOne: {
filter: { _id: room._id },
update: {
$set: {
uids: getIds(room._id),
},
},
},
}));
const batch = Promise.all(actions);
if (actions.length === 0) {
return;
}
const batch = await roomCollection.bulkWrite(actions, { ordered: false });
if (actions.length === batchSize) {
await batch;
return migrateDMs(models, total, current + batchSize);
@ -68,7 +77,7 @@ Migrations.add({
const total = await rooms.count();
await rooms.close();
if (total < batchSize * 2) {
if (total < batchSize * 10) {
await migrateDMs({ roomCollection }, total, 0);
return fut.return();
}

Loading…
Cancel
Save