Improve appstore listing speed

This commit is contained in:
Johannes Zellner
2021-09-23 01:14:55 +02:00
parent 195c5ab21a
commit 3a55daed2f
2 changed files with 43 additions and 62 deletions

View File

@@ -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) {