added browserify and made db.js an ES6 module

This commit is contained in:
typer 2020-11-12 23:12:53 -08:00
parent 8ade02f170
commit b879a5967d
10 changed files with 2665 additions and 101 deletions

View file

@ -1,25 +1,15 @@
const { task, src, dest, series, watch } = require("gulp");
const browserify = require("browserify");
const babelify = require("babelify");
const concat = require("gulp-concat");
const del = require("del");
const source = require("vinyl-source-stream");
const buffer = require("vinyl-buffer");
const vinylPaths = require("vinyl-paths");
const eslint = require("gulp-eslint");
var sass = require("gulp-sass");
sass.compiler = require("dart-sass");
//the order of files is important
const gulpSrc = [
"./src/js/misc.js",
"./src/js/words.js",
"./src/js/layouts.js",
"./src/js/db.js",
"./src/js/userconfig.js",
"./src/js/commandline.js",
"./src/js/leaderboards.js",
"./src/js/settings.js",
"./src/js/account.js",
"./src/js/script.js",
];
let eslintConfig = {
parser: "babel-eslint",
globals: [
@ -94,13 +84,33 @@ let eslintConfig = {
},
};
//refactored files, which should be es6 modules
//once all files are moved here, then can we use a bundler to its full potential
const refactoredSrc = ["./src/js/db.js"];
//legacy files
//the order of files is important
const globalSrc = [
"./src/js/global-dependencies.js",
"./src/js/misc.js",
"./src/js/words.js",
"./src/js/layouts.js",
"./src/js/userconfig.js",
"./src/js/commandline.js",
"./src/js/leaderboards.js",
"./src/js/settings.js",
"./src/js/account.js",
"./src/js/script.js",
];
//concatenates and lints legacy js files and writes the output to dist/gen/index.js
task("cat", function () {
return src(gulpSrc)
.pipe(concat("monkeytype.js"))
return src(globalSrc)
.pipe(concat("index.js"))
.pipe(eslint(eslintConfig))
.pipe(eslint.format())
.pipe(eslint.failAfterError())
.pipe(dest("./dist/js"));
.pipe(dest("./dist/gen"));
});
task("sass", function () {
@ -113,11 +123,50 @@ task("static", function () {
return src("./static/**/*").pipe(dest("./dist/"));
});
//copies refactored js files to dist/gen so that they can be required by dist/gen/index.js
task("copy-modules", function () {
return src(refactoredSrc, { allowEmpty: true }).pipe(dest("./dist/gen"));
});
//bundles the refactored js files together with index.js (the concatenated legacy js files)
//it's odd that the entry point is generated, so we should seek a better way of doing this
task("browserify", function () {
const b = browserify({
//index.js is generated by task "cat"
entries: "./dist/gen/index.js",
//a source map isn't very useful right now because
//the source files are concatenated together
debug: false,
});
return b
.transform(
babelify.configure({
presets: ["@babel/preset-env"],
plugins: ["@babel/transform-runtime"],
})
)
.bundle()
.pipe(source("monkeytype.js"))
.pipe(buffer())
.pipe(dest("./dist/js"));
});
//lints only the refactored files
task("lint", function () {
return src(refactoredSrc)
.pipe(eslint(eslintConfig))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
task("clean", function () {
return src("./dist/", { allowEmpty: true }).pipe(vinylPaths(del));
});
task("compile", series("static", "sass", "cat"));
task(
"compile",
series("lint", "cat", "copy-modules", "browserify", "static", "sass")
);
task("watch", function () {
watch(["./static/**/*", "./src/**/*"], series("compile"));

2473
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -15,7 +15,12 @@
"node": "10"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"babel-eslint": "^10.1.0",
"babelify": "^10.0.0",
"browserify": "^17.0.0",
"concurrently": "^5.3.0",
"dart-sass": "^1.25.0",
"del": "^6.0.0",
@ -27,11 +32,16 @@
"husky": "^4.3.0",
"prettier": "2.1.2",
"pretty-quick": "^3.1.0",
"vinyl-paths": "^3.0.1"
"vinyl-buffer": "^1.0.1",
"vinyl-paths": "^3.0.1",
"vinyl-source-stream": "^2.0.0"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
},
"dependencies": {
"@babel/runtime": "^7.12.5"
}
}

View file

@ -160,7 +160,7 @@ function signUp() {
console.log("Analytics unavailable");
}
$(".pageLogin .preloader").addClass("hidden");
dbSnapshot = {
db_setSnapshot({
results: [],
personalBests: {},
tags: [],
@ -169,14 +169,14 @@ function signUp() {
started: undefined,
completed: undefined,
},
};
});
if (notSignedInLastResult !== null) {
notSignedInLastResult.uid = usr.uid;
testCompleted({
uid: usr.uid,
obj: notSignedInLastResult,
});
dbSnapshot.results.push(notSignedInLastResult);
db_getSnapshot().results.push(notSignedInLastResult);
config.resultFilters = defaultAccountFilters;
}
changePage("account");
@ -225,7 +225,7 @@ function signOut() {
hideAccountSettingsSection();
updateAccountLoginButton();
changePage("login");
dbSnapshot = null;
db_setSnapshot(null);
})
.catch(function (error) {
showNotification(error.message, 5000);
@ -284,7 +284,7 @@ firebase.auth().onAuthStateChanged(function (user) {
verifyUser(verifyUserWhenLoggedIn).then((data) => {
showNotification(data.data.message, 3000);
if (data.data.status === 1) {
dbSnapshot.discordId = data.data.did;
db_getSnapshot().discordId = data.data.did;
updateDiscordSettingsSection();
}
});
@ -312,18 +312,18 @@ firebase.auth().onAuthStateChanged(function (user) {
function getAccountDataAndInit() {
db_getUserSnapshot()
.then((e) => {
if (dbSnapshot === null) {
if (db_getSnapshot() === null) {
throw "Missing db snapshot. Client likely could not connect to the backend.";
}
initPaceCaret(true);
if (!configChangedBeforeDb) {
if (cookieConfig === null) {
accountIconLoading(false);
applyConfig(dbSnapshot.config);
applyConfig(db_getSnapshot().config);
updateSettingsPage();
saveConfigToCookie(true);
restartTest(false, true);
} else if (dbSnapshot.config !== undefined) {
} else if (db_getSnapshot().config !== undefined) {
let configsDifferent = false;
Object.keys(config).forEach((key) => {
if (!configsDifferent) {
@ -331,18 +331,22 @@ function getAccountDataAndInit() {
if (key !== "resultFilters") {
if (Array.isArray(config[key])) {
config[key].forEach((arrval, index) => {
if (arrval != dbSnapshot.config[key][index]) {
if (arrval != db_getSnapshot().config[key][index]) {
configsDifferent = true;
console.log(
`.config is different: ${arrval} != ${dbSnapshot.config[key][index]}`
`.config is different: ${arrval} != ${
db_getSnapshot().config[key][index]
}`
);
}
});
} else {
if (config[key] != dbSnapshot.config[key]) {
if (config[key] != db_getSnapshot().config[key]) {
configsDifferent = true;
console.log(
`..config is different ${key}: ${config[key]} != ${dbSnapshot.config[key]}`
`..config is different ${key}: ${config[key]} != ${
db_getSnapshot().config[key]
}`
);
}
}
@ -357,7 +361,7 @@ function getAccountDataAndInit() {
if (configsDifferent) {
console.log("applying config from db");
accountIconLoading(false);
config = dbSnapshot.config;
config = db_getSnapshot().config;
applyConfig(config);
updateSettingsPage();
saveConfigToCookie(true);
@ -375,12 +379,12 @@ function getAccountDataAndInit() {
config.resultFilters.difficulty === undefined
) {
if (
dbSnapshot.config.resultFilters == null ||
dbSnapshot.config.resultFilters.difficulty === undefined
db_getSnapshot().config.resultFilters == null ||
db_getSnapshot().config.resultFilters.difficulty === undefined
) {
config.resultFilters = defaultAccountFilters;
} else {
config.resultFilters = dbSnapshot.config.resultFilters;
config.resultFilters = db_getSnapshot().config.resultFilters;
}
}
} catch (e) {
@ -1045,14 +1049,14 @@ function updateFilterTags() {
$(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
).empty();
if (dbSnapshot.tags.length > 0) {
if (db_getSnapshot().tags.length > 0) {
$(".pageAccount .content .filterButtons .buttonsAndTitle.tags").removeClass(
"hidden"
);
$(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
).append(`<div class="button" filter="none">no tag</div>`);
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
defaultAccountFilters.tags[tag.id] = true;
$(
".pageAccount .content .filterButtons .buttonsAndTitle.tags .buttons"
@ -1150,9 +1154,9 @@ function showActiveFilters() {
ret += aboveChartDisplay.tags.array
.map((id) => {
if (id == "none") return id;
let name = dbSnapshot.tags.filter((t) => t.id == id)[0];
let name = db_getSnapshot().tags.filter((t) => t.id == id)[0];
if (name !== undefined) {
return dbSnapshot.tags.filter((t) => t.id == id)[0].name;
return db_getSnapshot().tags.filter((t) => t.id == id)[0].name;
}
})
.join(", ");
@ -1278,7 +1282,7 @@ $(".pageAccount .topFilters .button.currentConfigFilter").click((e) => {
}
config.resultFilters.funbox[activeFunBox] = true;
config.resultFilters.tags.none = true;
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.active === true) {
config.resultFilters.tags.none = false;
config.resultFilters.tags[tag.id] = true;
@ -1398,7 +1402,7 @@ function fillPbTables() {
</tr>
`);
const pb = dbSnapshot.personalBests;
const pb = db_getSnapshot().personalBests;
let pbData;
let text;
@ -1637,7 +1641,7 @@ function loadMoreLines() {
if (result.tags !== undefined && result.tags.length > 0) {
result.tags.forEach((tag) => {
dbSnapshot.tags.forEach((snaptag) => {
db_getSnapshot().tags.forEach((snaptag) => {
if (tag === snaptag.id) {
tagNames += snaptag.name + ", ";
}
@ -1708,10 +1712,10 @@ function clearGlobalStats() {
}
function refreshGlobalStats() {
if (dbSnapshot.globalStats.time != undefined) {
let th = Math.floor(dbSnapshot.globalStats.time / 3600);
let tm = Math.floor((dbSnapshot.globalStats.time % 3600) / 60);
let ts = Math.floor((dbSnapshot.globalStats.time % 3600) % 60);
if (db_getSnapshot().globalStats.time != undefined) {
let th = Math.floor(db_getSnapshot().globalStats.time / 3600);
let tm = Math.floor((db_getSnapshot().globalStats.time % 3600) / 60);
let ts = Math.floor((db_getSnapshot().globalStats.time % 3600) % 60);
$(".pageAccount .globalTimeTyping .val").text(`
${th < 10 ? "0" + th : th}:${tm < 10 ? "0" + tm : tm}:${
@ -1719,14 +1723,14 @@ function refreshGlobalStats() {
}
`);
}
if (dbSnapshot.globalStats.started != undefined) {
if (db_getSnapshot().globalStats.started != undefined) {
$(".pageAccount .globalTestsStarted .val").text(
dbSnapshot.globalStats.started
db_getSnapshot().globalStats.started
);
}
if (dbSnapshot.globalStats.completed != undefined) {
if (db_getSnapshot().globalStats.completed != undefined) {
$(".pageAccount .globalTestsCompleted .val").text(
dbSnapshot.globalStats.completed
db_getSnapshot().globalStats.completed
);
}
}
@ -1775,7 +1779,7 @@ function refreshAccountPage() {
filteredResults = [];
$(".pageAccount .history table tbody").empty();
dbSnapshot.results.forEach((result) => {
db_getSnapshot().results.forEach((result) => {
let tt = 0;
if (result.testDuration == undefined) {
//test finished before testDuration field was introduced - estimate
@ -1849,14 +1853,14 @@ function refreshAccountPage() {
if (result.tags === undefined || result.tags.length === 0) {
//no tags, show when no tag is enabled
if (dbSnapshot.tags.length > 0) {
if (db_getSnapshot().tags.length > 0) {
if (config.resultFilters.tags.none) tagHide = false;
} else {
tagHide = false;
}
} else {
//tags exist
let validTags = dbSnapshot.tags.map((t) => t.id);
let validTags = db_getSnapshot().tags.map((t) => t.id);
result.tags.forEach((tag) => {
//check if i even need to check tags anymore
if (!tagHide) return;
@ -2232,10 +2236,10 @@ function refreshAccountPage() {
swapElements($(".pageAccount .preloader"), $(".pageAccount .content"), 250);
}
if (dbSnapshot === null) {
if (db_getSnapshot() === null) {
showNotification(`Missing account data. Please refresh.`, 5000);
$(".pageAccount .preloader").html("Missing account data. Please refresh.");
} else if (dbSnapshot.results === undefined) {
} else if (db_getSnapshot().results === undefined) {
db_getUserResults().then((d) => {
if (d) {
showActiveFilters();
@ -2292,7 +2296,7 @@ $(".pageAccount .toggleChartStyle").click((params) => {
});
$(document).on("click", ".pageAccount .group.history #resultEditTags", (f) => {
if (dbSnapshot.tags.length > 0) {
if (db_getSnapshot().tags.length > 0) {
let resultid = $(f.target).parents("span").attr("resultid");
let tags = $(f.target).parents("span").attr("tags");
$("#resultEditTagsPanel").attr("resultid", resultid);
@ -2314,7 +2318,7 @@ $("#resultEditTagsPanelWrapper").click((e) => {
function updateResultEditTagsPanelButtons() {
$("#resultEditTagsPanel .buttons").empty();
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
$("#resultEditTagsPanel .buttons").append(
`<div class="button tag" tagid="${tag.id}">${tag.name}</div>`
);
@ -2354,7 +2358,7 @@ $("#resultEditTagsPanel .confirmButton").click((f) => {
hideBackgroundLoader();
if (r.data.resultCode === 1) {
showNotification("Tags updated.", 3000);
dbSnapshot.results.forEach((result) => {
db_getSnapshot().results.forEach((result) => {
if (result.id === resultid) {
result.tags = newtags;
}
@ -2364,7 +2368,7 @@ $("#resultEditTagsPanel .confirmButton").click((f) => {
if (newtags.length > 0) {
newtags.forEach((tag) => {
dbSnapshot.tags.forEach((snaptag) => {
db_getSnapshot().tags.forEach((snaptag) => {
if (tag === snaptag.id) {
tagNames += snaptag.name + ", ";
}
@ -2410,5 +2414,5 @@ $("#resultEditTagsPanel .confirmButton").click((f) => {
});
function updateLbMemory(mode, mode2, type, value) {
dbSnapshot.lbMemory[mode + mode2][type] = value;
db_getSnapshot().lbMemory[mode + mode2][type] = value;
}

View file

@ -1467,14 +1467,14 @@ let commandsTags = {
};
function updateCommandsTagsList() {
if (dbSnapshot.tags.length > 0) {
if (db_getSnapshot().tags.length > 0) {
commandsTags.list = [];
commandsTags.list.push({
id: "clearTags",
display: "Clear tags",
exec: () => {
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
tag.active = false;
});
updateTestModesNotice();
@ -1482,7 +1482,7 @@ function updateCommandsTagsList() {
},
});
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
let dis = tag.name;
if (tag.active === true) {

View file

@ -3,7 +3,15 @@ db.settings({ experimentalForceLongPolling: true });
let dbSnapshot = null;
async function db_getUserSnapshot() {
export function db_getSnapshot() {
return dbSnapshot;
}
export function db_setSnapshot(newSnapshot) {
dbSnapshot = newSnapshot;
}
export async function db_getUserSnapshot() {
let user = firebase.auth().currentUser;
if (user == null) return false;
let snap = {
@ -71,7 +79,7 @@ async function db_getUserSnapshot() {
return dbSnapshot;
}
async function db_getUserResults() {
export async function db_getUserResults() {
let user = firebase.auth().currentUser;
if (user == null) return false;
if (dbSnapshot === null) return false;
@ -103,7 +111,7 @@ async function db_getUserResults() {
}
}
async function db_getUserHighestWpm(
export async function db_getUserHighestWpm(
mode,
mode2,
punctuation,
@ -137,7 +145,13 @@ async function db_getUserHighestWpm(
return retval;
}
async function db_getLocalPB(mode, mode2, punctuation, language, difficulty) {
export async function db_getLocalPB(
mode,
mode2,
punctuation,
language,
difficulty
) {
function cont() {
let ret = 0;
try {
@ -164,7 +178,7 @@ async function db_getLocalPB(mode, mode2, punctuation, language, difficulty) {
return retval;
}
async function db_saveLocalPB(
export async function db_saveLocalPB(
mode,
mode2,
punctuation,

View file

@ -0,0 +1,9 @@
import {
db_getSnapshot,
db_setSnapshot,
db_getUserSnapshot,
db_getUserResults,
db_getUserHighestWpm,
db_getLocalPB,
db_saveLocalPB,
} from "./db";

View file

@ -1907,7 +1907,7 @@ function showResult(difficultyFailed = false) {
} else {
let activeTags = [];
try {
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.active === true) {
activeTags.push(tag.id);
}
@ -2073,24 +2073,27 @@ function showResult(difficultyFailed = false) {
if (e.data.resultCode === 2) {
completedEvent.isPb = true;
}
if (dbSnapshot !== null && dbSnapshot.results !== undefined) {
dbSnapshot.results.unshift(completedEvent);
if (dbSnapshot.globalStats.time == undefined) {
dbSnapshot.globalStats.time =
if (
db_getSnapshot() !== null &&
db_getSnapshot().results !== undefined
) {
db_getSnapshot().results.unshift(completedEvent);
if (db_getSnapshot().globalStats.time == undefined) {
db_getSnapshot().globalStats.time =
testtime + completedEvent.incompleteTestSeconds;
} else {
dbSnapshot.globalStats.time +=
db_getSnapshot().globalStats.time +=
testtime + completedEvent.incompleteTestSeconds;
}
if (dbSnapshot.globalStats.started == undefined) {
dbSnapshot.globalStats.started = restartCount + 1;
if (db_getSnapshot().globalStats.started == undefined) {
db_getSnapshot().globalStats.started = restartCount + 1;
} else {
dbSnapshot.globalStats.started += restartCount + 1;
db_getSnapshot().globalStats.started += restartCount + 1;
}
if (dbSnapshot.globalStats.completed == undefined) {
dbSnapshot.globalStats.completed = 1;
if (db_getSnapshot().globalStats.completed == undefined) {
db_getSnapshot().globalStats.completed = 1;
} else {
dbSnapshot.globalStats.completed += 1;
db_getSnapshot().globalStats.completed += 1;
}
}
try {
@ -2104,7 +2107,7 @@ function showResult(difficultyFailed = false) {
if (
config.mode === "time" &&
(mode2 == "15" || mode2 == "60") &&
dbSnapshot !== null
db_getSnapshot() !== null
) {
const lbUpIcon = `<i class="fas fa-angle-up"></i>`;
const lbDownIcon = `<i class="fas fa-angle-down"></i>`;
@ -2113,8 +2116,9 @@ function showResult(difficultyFailed = false) {
//global
let globalLbString = "";
const glb = e.data.globalLeaderboard;
const glbMemory =
dbSnapshot.lbMemory[config.mode + mode2].global;
const glbMemory = db_getSnapshot().lbMemory[
config.mode + mode2
].global;
let dontShowGlobalDiff =
glbMemory == null || glbMemory === -1 ? true : false;
let globalLbDiff = null;
@ -2169,8 +2173,9 @@ function showResult(difficultyFailed = false) {
//daily
let dailyLbString = "";
const dlb = e.data.dailyLeaderboard;
const dlbMemory =
dbSnapshot.lbMemory[config.mode + mode2].daily;
const dlbMemory = db_getSnapshot().lbMemory[
config.mode + mode2
].daily;
let dontShowDailyDiff =
dlbMemory == null || dlbMemory === -1 ? true : false;
let dailyLbDiff = null;
@ -2226,7 +2231,7 @@ function showResult(difficultyFailed = false) {
saveLbMemory({
uid: firebase.auth().currentUser.uid,
obj: dbSnapshot.lbMemory,
obj: db_getSnapshot().lbMemory,
}).then((d) => {
if (d.data.returnCode === 1) {
} else {
@ -2399,7 +2404,7 @@ function showResult(difficultyFailed = false) {
let tagsText = "";
try {
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.active === true) {
tagsText += "<br>" + tag.name;
}
@ -3351,7 +3356,7 @@ function updateTestModesNotice() {
let tagsString = "";
try {
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.active === true) {
tagsString += tag.name + ", ";
}
@ -3412,7 +3417,7 @@ function tagsEdit() {
let status = e.data.resultCode;
if (status === 1) {
showNotification("Tag added", 2000);
dbSnapshot.tags.push({
db_getSnapshot().tags.push({
name: inputVal,
id: e.data.id,
});
@ -3437,7 +3442,7 @@ function tagsEdit() {
let status = e.data.resultCode;
if (status === 1) {
showNotification("Tag updated", 2000);
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.id === tagid) {
tag.name = inputVal;
}
@ -3459,9 +3464,9 @@ function tagsEdit() {
let status = e.data.resultCode;
if (status === 1) {
showNotification("Tag removed", 2000);
dbSnapshot.tags.forEach((tag, index) => {
db_getSnapshot().tags.forEach((tag, index) => {
if (tag.id === tagid) {
dbSnapshot.tags.splice(index, 1);
db_getSnapshot().tags.splice(index, 1);
}
});
updateResultEditTagsPanelButtons();

View file

@ -548,9 +548,9 @@ function hideAccountSettingsSection() {
}
function refreshTagsSettingsSection() {
if (firebase.auth().currentUser !== null && dbSnapshot !== null) {
if (firebase.auth().currentUser !== null && db_getSnapshot() !== null) {
let tagsEl = $(".pageSettings .section.tags .tagsList").empty();
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.active === true) {
tagsEl.append(`
@ -618,7 +618,7 @@ function setCustomThemeInputs() {
}
function showActiveTags() {
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.active === true) {
$(
`.pageSettings .section.tags .tagsList .tag[id='${tag.id}'] .active`
@ -632,7 +632,7 @@ function showActiveTags() {
}
function toggleTag(tagid, nosave = false) {
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.id === tagid) {
if (tag.active === undefined) {
tag.active = true;
@ -650,10 +650,10 @@ function updateDiscordSettingsSection() {
if (firebase.auth().currentUser == null) {
$(".pageSettings .section.discordIntegration").addClass("hidden");
} else {
if (dbSnapshot == null) return;
if (db_getSnapshot() == null) return;
$(".pageSettings .section.discordIntegration").removeClass("hidden");
if (dbSnapshot.discordId == undefined) {
if (db_getSnapshot().discordId == undefined) {
//show button
$(".pageSettings .section.discordIntegration .buttons").removeClass(
"hidden"
@ -719,7 +719,7 @@ $(
.then((ret) => {
hideBackgroundLoader();
if (ret.data.status === 1 || ret.data.status === 2) {
dbSnapshot.pairingCode = ret.data.pairingCode;
db_getSnapshot().pairingCode = ret.data.pairingCode;
$(".pageSettings .section.discordIntegration .code .bottom").text(
ret.data.pairingCode
);
@ -743,7 +743,7 @@ $(".pageSettings .section.discordIntegration #unlinkDiscordButton").click(
hideBackgroundLoader();
console.log(ret);
if (ret.data.status === 1) {
dbSnapshot.discordId = null;
db_getSnapshot().discordId = null;
showNotification("Accounts unlinked", 2000);
updateDiscordSettingsSection();
} else {

View file

@ -128,7 +128,7 @@ function saveActiveTagsToCookie() {
let tags = [];
try {
dbSnapshot.tags.forEach((tag) => {
db_getSnapshot().tags.forEach((tag) => {
if (tag.active === true) {
tags.push(tag.id);
}