Skip to content

Commit

Permalink
#8381 replace future by promise (fixes RocketChat#10110 (comment))
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurz committed Apr 15, 2018
1 parent 1cd2dbd commit a8ff9da
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions packages/chatpal-search/server/provider/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import ChatpalLogger from '../utils/logger';
import { Random } from 'meteor/random';

const Future = Npm.require('fibers/future');

/**
* Enables HTTP functions on Chatpal Backend
*/
Expand Down Expand Up @@ -339,7 +337,7 @@ export default class Index {
return start.getTime();
}

_run(date, fut) {
_run(date, resolve, reject) {

this._running = true;

Expand All @@ -348,7 +346,7 @@ export default class Index {
Meteor.setTimeout(() => {
date = this._indexMessages(date, (this._options.windowSize || 24) * 3600000);

this._run(date, fut);
this._run(date, resolve, reject);

}, this._options.timeout || 1000);
} else if (this._break) {
Expand All @@ -358,7 +356,7 @@ export default class Index {

this._running = false;

fut.return();
resolve();
} else {

ChatpalLogger.info(`No messages older than already indexed date ${ new Date(date).toString() }`);
Expand All @@ -381,24 +379,24 @@ export default class Index {

this._running = false;

fut.return();
resolve();
}
}

_bootstrap(clear, date) {

ChatpalLogger.info('Start bootstrapping');

const fut = new Future();
return new Promise((resolve, reject) => {

if (clear) {
this._backend.clear();
date = new Date().getTime();
}
if (clear) {
this._backend.clear();
date = new Date().getTime();
}

this._run(date, fut);
this._run(date, resolve, reject);

return fut;
});
}

static ping(options) {
Expand Down

0 comments on commit a8ff9da

Please sign in to comment.