Enable chapters if not enabled after redeem successful

This commit is contained in:
Ajay
2022-10-10 00:38:09 -04:00
parent f4cac58322
commit 5d62b11a6d

View File

@@ -3,11 +3,15 @@ import { checkLicenseKey } from "./utils/licenseKey";
import { localizeHtmlPage } from "./utils/pageUtils"; import { localizeHtmlPage } from "./utils/pageUtils";
import * as countries from "../public/res/countries.json"; import * as countries from "../public/res/countries.json";
import Utils from "./utils";
import { Category, CategorySkipOption } from "./types";
// This is needed, if Config is not imported before Utils, things break. // This is needed, if Config is not imported before Utils, things break.
// Probably due to cyclic dependencies // Probably due to cyclic dependencies
Config.config; Config.config;
const utils = new Utils();
window.addEventListener('DOMContentLoaded', init); window.addEventListener('DOMContentLoaded', init);
async function init() { async function init() {
@@ -31,6 +35,13 @@ async function init() {
Config.config.payments.licenseKey = licenseKey; Config.config.payments.licenseKey = licenseKey;
Config.forceSyncUpdate("payments"); Config.forceSyncUpdate("payments");
if (!utils.getCategorySelection("chapter")) {
Config.config.categorySelections.push({
name: "chapter" as Category,
option: CategorySkipOption.ShowOverlay
});
}
alert(chrome.i18n.getMessage("redeemSuccess")); alert(chrome.i18n.getMessage("redeemSuccess"));
} else { } else {
alert(chrome.i18n.getMessage("redeemFailed")); alert(chrome.i18n.getMessage("redeemFailed"));