all files / src/api/ block-list-settings-api.js

97.67% Statements 42/43
88.89% Branches 16/18
100% Functions 9/9
93.75% Lines 15/16
2 statements, 5 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                           
import { SettingsApi } from 'riotclient-async-provider-proxy'
import loggerConstructor from '../lib/logger'
 
let logger = loggerConstructor('api:block-list-settings');
 
class BlockListSettingsApi {
 
  constructor(subDoc) {
    this.namespace = 'lol-block-list';
    this.category = 'lol-block-list';
    this.schemaVersion = 1;
    this.settingScope = 'account';
    this.subDoc = subDoc;
    this.registerSettingComponent();
  }
 
  registerSettingComponent() {
    this.blockListSettingsContext = SettingsApi.registerSettings(this.namespace,
        this.category, this.schemaVersion, this.settingScope);
 
    this.blockListSettingsContext.setRenderer((data, version) => {
      Iif (version && version < this.schemaVersion) {
        logger.warn("Schema version is too old. Needs to update.");
      }
 
      return document.createElement('lol-blocked-summoners');
    });
 
    logger.debug("blockList settings component has been registered.");
  }
 
}
 
module.exports = BlockListSettingsApi;