mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-27 21:05:53 +00:00
4.14.2
* Added: Additional settings for controlling the behavior of Twitch's native Chat Filters. * Added: Upload strings directly from the Translation Tester UI. (This is for me only, but I like it.) * Changed: Allow resizing text entry boxes in the Translation Tester UI. * Fixed: Emoji categories were not being localized.
This commit is contained in:
parent
b53e0e6427
commit
3b7e99e5a3
10 changed files with 198 additions and 14 deletions
|
@ -110,6 +110,50 @@ export default class SocketClient extends Module {
|
|||
}
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// FFZ API Helpers
|
||||
// ========================================================================
|
||||
|
||||
getAPIToken() {
|
||||
if ( this._cached_token ) {
|
||||
if ( this._cached_token.expires > (Date.now() + 15000) )
|
||||
return Promise.resolve(this._cached_token);
|
||||
}
|
||||
|
||||
if ( this._token_waiters )
|
||||
return new Promise((s, f) => this._token_waiters.push([s, f]));
|
||||
|
||||
this._token_waiters = [];
|
||||
|
||||
return new Promise((s, f) => {
|
||||
this._token_waiters.push([s, f]);
|
||||
|
||||
this.call('get_api_token').then(token => {
|
||||
token.expires = (new Date(token.expires)).getTime();
|
||||
this._cached_token = token;
|
||||
|
||||
const waiters = this._token_waiters;
|
||||
this._token_waiters = null;
|
||||
|
||||
for(const pair of waiters)
|
||||
pair[0](token);
|
||||
|
||||
}).catch(err => {
|
||||
this.log.error('Unable to get API token.', err);
|
||||
const waiters = this._token_waiters;
|
||||
this._token_waiters = null;
|
||||
|
||||
for(const pair of waiters)
|
||||
pair[1](err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async getBareAPIToken() {
|
||||
return (await this.getAPIToken())?.token;
|
||||
}
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// Connection Logic
|
||||
// ========================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue