Improve appstore listing speed
This commit is contained in:
@@ -372,7 +372,6 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
this._configListener = [];
|
||||
this._readyListener = [];
|
||||
this._reconnectListener = [];
|
||||
this._fetchingAppstoreAppsListener = [];
|
||||
this._userInfo = {
|
||||
id: null,
|
||||
username: null,
|
||||
@@ -2834,32 +2833,20 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
Client.prototype.getAppstoreApps = function (callback) {
|
||||
var that = this;
|
||||
|
||||
if (that._fetchingAppstoreApps) return this.getAppstoreAppsFast(callback);
|
||||
|
||||
that._fetchingAppstoreApps = true;
|
||||
|
||||
get('/api/v1/appstore/apps', null, function (error, data, status) {
|
||||
that._fetchingAppstoreApps = false;
|
||||
|
||||
if (error) return callback(error);
|
||||
if (status !== 200) return callback(new ClientError(status, data));
|
||||
|
||||
angular.copy(data.apps, that._appstoreAppCache);
|
||||
|
||||
that._fetchingAppstoreAppsListener.forEach(function (callback) { callback(); });
|
||||
that._fetchingAppstoreAppsListener = [];
|
||||
|
||||
return callback(null, that._appstoreAppCache);
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.getAppstoreAppsFast = function (callback) {
|
||||
var that = this;
|
||||
|
||||
if (this._appstoreAppCache.length !== 0) return callback(null, this._appstoreAppCache);
|
||||
if (!that._fetchingAppstoreApps) return this.getAppstoreApps(callback);
|
||||
|
||||
this._onAppstoreApps(function () { that.getAppstoreAppsFast(callback) });
|
||||
this.getAppstoreApps(callback);
|
||||
};
|
||||
|
||||
Client.prototype.getSubscription = function (callback) {
|
||||
|
||||
Reference in New Issue
Block a user