refactor: Splitting API requests from app.js (#1166)

* splitting API requests form app.js

* fix: vip friends display issue
This commit is contained in:
pa
2025-03-03 07:42:29 +09:00
committed by GitHub
parent f1fb44840e
commit 41c47d3dc2
21 changed files with 1881 additions and 1623 deletions

View File

@@ -297,14 +297,28 @@ export default class extends baseClass {
};
API.bulk = function (options) {
this[options.fn](options.params)
.catch((err) => {
if ('done' in options) {
options.done.call(this, false, options);
}
throw err;
})
.then((args) => this.$bulk(options, args));
// it's stupid, but I won't waste time on the 'this' context
// works, that's enough.
if (typeof options.fn === 'function') {
options
.fn(options.params)
.catch((err) => {
if ('done' in options) {
options.done.call(this, false, options);
}
throw err;
})
.then((args) => this.$bulk(options, args));
} else {
this[options.fn](options.params)
.catch((err) => {
if ('done' in options) {
options.done.call(this, false, options);
}
throw err;
})
.then((args) => this.$bulk(options, args));
}
};
API.statusCodes = {