Skip to content

Commit

Permalink
Merge pull request popcorn-official#2821 from popcorn-time-ru/remove-…
Browse files Browse the repository at this point in the history
…some-q
  • Loading branch information
kiriles90 authored Jan 17, 2024
2 parents 82d2be1 + 00e84c7 commit f490c20
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
16 changes: 8 additions & 8 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,15 @@ var initTemplates = function () {
var ts = [];

_.each(document.querySelectorAll('[type="text/x-template"]'), function (el) {
var d = Q.defer();
$.get(el.src, function (res) {
el.innerHTML = res;
d.resolve(true);
});
ts.push(d.promise);
ts.push(new Promise((resolve, reject) => {
$.get(el.src, function (res) {
el.innerHTML = res;
resolve(true);
});
}));
});

return Q.all(ts);
return Promise.all(ts);
};

var initApp = function () {
Expand Down Expand Up @@ -544,7 +544,7 @@ var handleVideoFile = function (file) {

// get subtitles from provider
var getSubtitles = function (subdata) {
return Q.Promise(function (resolve, reject) {
return new Promise(function (resolve, reject) {
win.debug('Subtitles data request:', subdata);

var subtitleProvider = App.Config.getProviderForType('subtitle');
Expand Down
33 changes: 15 additions & 18 deletions src/app/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
var fs = require('fs');

function loadLocalProviders() {
var appPath = '';
var providerPath = './src/app/lib/providers/';

var files = fs.readdirSync(providerPath);

var head = document.getElementsByTagName('head')[0];
return files
.map(function(file) {
if (!file.match(/\.js$/) || file.match(/generic.js$/)) {
Expand All @@ -20,23 +20,20 @@

win.info('loading local provider', file);

var q = Q.defer();
return new Promise((resolve, reject) => {
var script = document.createElement('script');

var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'lib/providers/' + file;

script.type = 'text/javascript';
script.src = 'lib/providers/' + file;

script.onload = function() {
this.onload = null;
win.info('loaded', file);
q.resolve(file);
};

head.appendChild(script);
script.onload = function() {
script.onload = null;
win.info('loaded', file);
resolve(file);
};

return q.promise;
head.appendChild(script);
});
})
.filter(function(q) {
return q;
Expand Down Expand Up @@ -75,21 +72,21 @@
}

function loadNpmSettings() {
return Q.all(
return Promise.all(
loadFromPackageJSON(/butter-settings-/, function(settings) {
Settings = _.extend(Settings, settings);
})
);
}

function loadProviders() {
return Q.all(
return Promise.all(
loadLocalProviders()
);
}

function loadProvidersDelayed() {
return Q.all(
return Promise.all(
loadNpmProviders().concat(loadLegacyNpmProviders())
);
}
Expand Down
7 changes: 2 additions & 5 deletions src/app/lib/models/generic_collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
'use strict';

var getDataFromProvider = function (providers, collection) {
var deferred = Q.defer();
var filters = Object.assign(collection.filter, {page: providers.torrent.page});
providers.torrent.fetch(filters)
return providers.torrent.fetch(filters)
.then(function (torrents) {
// If a new request was started...
_.each(torrents.results, function (movie) {
Expand All @@ -25,14 +24,12 @@
movie.providers = providers;
});

return deferred.resolve(torrents);
return torrents;
})
.catch(function (err) {
collection.state = 'error';
collection.trigger('loaded', collection, collection.state);
});

return deferred.promise;
};

var PopCollection = Backbone.Collection.extend({
Expand Down

0 comments on commit f490c20

Please sign in to comment.