From 567708b7f15879e271964869544ebf2babf9405f Mon Sep 17 00:00:00 2001 From: SirStendec Date: Wed, 19 Jun 2019 13:55:04 -0400 Subject: [PATCH] 4.5.2 * Added: Setting to hide the "New Settings" badge that displays on the FFZ Control Center button when there are new settings. * Fixed: Incorrect locale detection causing Algolia queries to fail when loading auto-completion for tags. --- src/main.js | 2 +- .../twitch-twilight/modules/menu_button.jsx | 13 +++++- src/utilities/twitch-data.js | 45 ++++++++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index a03a6cde..2a1fa424 100644 --- a/src/main.js +++ b/src/main.js @@ -151,7 +151,7 @@ ${typeof x[1] === 'string' ? x[1] : JSON.stringify(x[1], null, 4)}` FrankerFaceZ.Logger = Logger; const VER = FrankerFaceZ.version_info = { - major: 4, minor: 5, revision: 1, + major: 4, minor: 5, revision: 2, commit: __git_commit__, build: __webpack_hash__, toString: () => diff --git a/src/sites/twitch-twilight/modules/menu_button.jsx b/src/sites/twitch-twilight/modules/menu_button.jsx index ff878150..539e6a6a 100644 --- a/src/sites/twitch-twilight/modules/menu_button.jsx +++ b/src/sites/twitch-twilight/modules/menu_button.jsx @@ -13,6 +13,7 @@ export default class MenuButton extends SiteModule { super(...args); this.inject('i18n'); + this.inject('settings'); this.inject('site.fine'); this.should_enable = true; @@ -21,6 +22,16 @@ export default class MenuButton extends SiteModule { this._important_update = false; this._new_settings = 0; + this.settings.add('ffz.show-new-settings', { + default: true, + ui: { + path: 'Appearance > Layout >> Top Navigation', + title: 'Display an indicator on the FFZ Control Center button whenever there are new settings added to FrankerFaceZ.', + component: 'setting-check-box' + }, + changed: () => this.update() + }); + this.NavBar = this.fine.define( 'nav-bar', n => n.renderOnsiteNotifications && n.renderTwitchPrimeCrown @@ -40,7 +51,7 @@ export default class MenuButton extends SiteModule { } get has_new() { - return this._new_settings > 0 + return this.settings.get('ffz.show-new-settings') && this._new_settings > 0; } get important_update() { diff --git a/src/utilities/twitch-data.js b/src/utilities/twitch-data.js index 1c82d8ae..0b2163ee 100644 --- a/src/utilities/twitch-data.js +++ b/src/utilities/twitch-data.js @@ -10,6 +10,49 @@ import {get, debounce, generateUUID} from 'utilities/object'; const LANGUAGE_MATCHER = /^auto___lang_(\w+)$/; +const ALGOLIA_LANGUAGES = { + bg: 'bg-bg', + cs: 'cs-cz', + da: 'da-dk', + de: 'de-de', + el: 'el-gr', + en: 'en-us', + es: 'es-es', + 'es-mx': 'es-mx', + fi: 'fi-fi', + fr: 'fr-fr', + hu: 'hu-hu', + it: 'it-it', + ja: 'ja-jp', + ko: 'ko-kr', + nl: 'nl-nl', + no: 'no-no', + pl: 'pl-pl', + 'pt-br': 'pt-br', + pt: 'pt-pt', + ro: 'ro-ro', + ru: 'ru-ru', + sk: 'sk-sk', + sv: 'sv-se', + th: 'th-th', + tr: 'tr-tr', + vi: 'vi-vn', + 'zh-cn': 'zh-cn', + 'zh-tw': 'zh-tw' +}; + +function getAlgoliaLanguage(locale) { + if ( ! locale ) + return ALGOLIA_LANGUAGES.en; + + locale = locale.toLowerCase(); + if ( ALGOLIA_LANGUAGES[locale] ) + return ALGOLIA_LANGUAGES[locale]; + + locale = locale.split('-')[0]; + return ALGOLIA_LANGUAGES[locale] || ALGOLIA_LANGUAGES.en; +} + export default class TwitchData extends Module { constructor(...args) { super(...args); @@ -432,7 +475,7 @@ export default class TwitchData extends Module { if ( ! locale ) locale = this.locale; - locale = locale.toLowerCase(); + locale = getAlgoliaLanguage(locale); let nodes;