1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00

More bugfixes. Actually implement the API test experiment.

This commit is contained in:
SirStendec 2018-04-12 02:29:43 -04:00
parent 99f9974dea
commit 1b2ff27530
10 changed files with 57 additions and 13 deletions

View file

@ -7,7 +7,7 @@
import Module from 'utilities/module';
import {ManagedStyle} from 'utilities/dom';
import {has, timeout, SourcedSet} from 'utilities/object';
import {CLIENT_ID, API_SERVER, IS_OSX} from 'utilities/constants';
import {CLIENT_ID, NEW_API, API_SERVER, IS_OSX} from 'utilities/constants';
const MOD_KEY = IS_OSX ? 'metaKey' : 'ctrlKey';
@ -60,6 +60,7 @@ export default class Emotes extends Module {
this.inject('socket');
this.inject('settings');
this.inject('experiments');
this.twitch_inventory_sets = new Set(EXTRA_INVENTORY);
this.__twitch_emote_to_set = new Map;
@ -133,9 +134,13 @@ export default class Emotes extends Module {
providers = emote_sets._sources;
if ( providers && providers.has('featured') )
for(const item of providers.get('featured'))
if ( ! new_sets.includes(item) )
for(const item of providers.get('featured')) {
const idx = new_sets.indexOf(item);
if ( idx === -1 )
room.removeSet('featured', item);
else
new_sets.splice(idx, 1);
}
for(const set_id of new_sets) {
room.addSet('featured', set_id);
@ -424,6 +429,12 @@ export default class Emotes extends Module {
async loadGlobalSets(tries = 0) {
let response, data;
if ( this.experiments.getAssignment('api_load') )
try {
fetch(`${NEW_API}/v1/set/global`).catch(() => {});
} catch(err) { /* do nothing */ }
try {
response = await fetch(`${API_SERVER}/v1/set/global`)
} catch(err) {
@ -461,6 +472,12 @@ export default class Emotes extends Module {
async loadSet(set_id, suppress_log = false, tries = 0) {
let response, data;
if ( this.experiments.getAssignment('api_load') )
try {
fetch(`${NEW_API}/v1/set/${set_id}`).catch(() => {});
} catch(err) { /* do nothing */ }
try {
response = await fetch(`${API_SERVER}/v1/set/${set_id}`)
} catch(err) {