From 1a456da017aa1a9b2c03ec67e1263d5c5d63e1c7 Mon Sep 17 00:00:00 2001 From: Jessica Lawshe Date: Mon, 25 Nov 2019 07:29:40 -0600 Subject: [PATCH] Merge pull request #2387 from overleaf/jel-async-login Convert V1LoginController._login to async GitOrigin-RevId: 2e51533126919f5a4ce71ca5d403a24773375333 --- .../Features/Subscription/FeaturesUpdater.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/services/web/app/src/Features/Subscription/FeaturesUpdater.js b/services/web/app/src/Features/Subscription/FeaturesUpdater.js index 0c7c250448..0a7698f7fb 100644 --- a/services/web/app/src/Features/Subscription/FeaturesUpdater.js +++ b/services/web/app/src/Features/Subscription/FeaturesUpdater.js @@ -12,7 +12,6 @@ * DS207: Consider shorter variations of null checks * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md */ -let FeaturesUpdater const async = require('async') const PlansLocator = require('./PlansLocator') const _ = require('underscore') @@ -27,7 +26,7 @@ const UserGetter = require('../User/UserGetter') const oneMonthInSeconds = 60 * 60 * 24 * 30 -module.exports = FeaturesUpdater = { +const FeaturesUpdater = { refreshFeatures(user_id, callback) { if (callback == null) { callback = function(error, features, featuresChanged) {} @@ -227,3 +226,23 @@ module.exports = FeaturesUpdater = { } } } + +const refreshFeaturesPromise = user_id => + new Promise(function(resolve, reject) { + FeaturesUpdater.refreshFeatures( + user_id, + (error, features, featuresChanged) => { + if (error) { + reject(error) + } else { + resolve({ features, featuresChanged }) + } + } + ) + }) + +FeaturesUpdater.promises = { + refreshFeatures: refreshFeaturesPromise +} + +module.exports = FeaturesUpdater