mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-13 15:36:42 +08:00
added account icon module. part of #495
This commit is contained in:
parent
44bb61c734
commit
4ab82b5e3d
7 changed files with 24 additions and 24 deletions
|
@ -109,6 +109,7 @@ const refactoredSrc = [
|
|||
"./src/js/config.js",
|
||||
"./src/js/config-set.js",
|
||||
"./src/js/test/focus.js",
|
||||
"./src/js/account-icon.js",
|
||||
];
|
||||
|
||||
//legacy files
|
||||
|
|
11
src/js/account-icon.js
Normal file
11
src/js/account-icon.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
export function loading(truefalse) {
|
||||
if (truefalse) {
|
||||
$("#top #menu .account .icon").html(
|
||||
'<i class="fas fa-fw fa-spin fa-circle-notch"></i>'
|
||||
);
|
||||
$("#top #menu .account").css("opacity", 1).css("pointer-events", "none");
|
||||
} else {
|
||||
$("#top #menu .account .icon").html('<i class="fas fa-fw fa-user"></i>');
|
||||
$("#top #menu .account").css("opacity", 1).css("pointer-events", "auto");
|
||||
}
|
||||
}
|
|
@ -252,7 +252,7 @@ firebase.auth().onAuthStateChanged(function (user) {
|
|||
);
|
||||
}
|
||||
updateAccountLoginButton();
|
||||
accountIconLoading(true);
|
||||
AccountIcon.loading(true);
|
||||
getAccountDataAndInit();
|
||||
var displayName = user.displayName;
|
||||
// var email = user.email;
|
||||
|
@ -362,7 +362,7 @@ function getAccountDataAndInit() {
|
|||
}
|
||||
if (!configChangedBeforeDb) {
|
||||
if (cookieConfig === null) {
|
||||
accountIconLoading(false);
|
||||
AccountIcon.loading(false);
|
||||
applyConfig(DB.getSnapshot().config);
|
||||
updateSettingsPage();
|
||||
saveConfigToCookie(true);
|
||||
|
@ -402,7 +402,7 @@ function getAccountDataAndInit() {
|
|||
// });
|
||||
// if (configsDifferent) {
|
||||
// console.log("applying config from db");
|
||||
// accountIconLoading(false);
|
||||
// AccountIcon.loading(false);
|
||||
// config = DB.getSnapshot().config;
|
||||
// applyConfig(config);
|
||||
// updateSettingsPage();
|
||||
|
@ -412,7 +412,7 @@ function getAccountDataAndInit() {
|
|||
}
|
||||
dbConfigLoaded = true;
|
||||
} else {
|
||||
accountIconLoading(false);
|
||||
AccountIcon.loading(false);
|
||||
}
|
||||
if (Config.paceCaret === "pb" || Config.paceCaret === "average") {
|
||||
if (!testActive) {
|
||||
|
@ -456,7 +456,7 @@ function getAccountDataAndInit() {
|
|||
changePage("account");
|
||||
}
|
||||
refreshThemeButtons();
|
||||
accountIconLoading(false);
|
||||
AccountIcon.loading(false);
|
||||
updateFilterTags();
|
||||
updateCommandsTagsList();
|
||||
loadActiveTagsFromCookie();
|
||||
|
@ -464,7 +464,7 @@ function getAccountDataAndInit() {
|
|||
showAccountSettingsSection();
|
||||
})
|
||||
.catch((e) => {
|
||||
accountIconLoading(false);
|
||||
AccountIcon.loading(false);
|
||||
console.error(e);
|
||||
Notifications.add(
|
||||
"Error downloading user data - refresh to try again. Client likely could not connect to the backend, if error persists contact Miodec.",
|
||||
|
|
|
@ -9,18 +9,6 @@ export function hideBackgroundLoader() {
|
|||
$("#backgroundLoader").stop(true, true).fadeOut(125);
|
||||
}
|
||||
|
||||
export function accountIconLoading(truefalse) {
|
||||
if (truefalse) {
|
||||
$("#top #menu .account .icon").html(
|
||||
'<i class="fas fa-fw fa-spin fa-circle-notch"></i>'
|
||||
);
|
||||
$("#top #menu .account").css("opacity", 1).css("pointer-events", "none");
|
||||
} else {
|
||||
$("#top #menu .account .icon").html('<i class="fas fa-fw fa-user"></i>');
|
||||
$("#top #menu .account").css("opacity", 1).css("pointer-events", "auto");
|
||||
}
|
||||
}
|
||||
|
||||
export function swapElements(
|
||||
el1,
|
||||
el2,
|
||||
|
@ -237,7 +225,7 @@ export function updateTestModesNotice(
|
|||
}
|
||||
}
|
||||
|
||||
function focusWords() {
|
||||
export function focusWords() {
|
||||
if (!$("#wordsWrapper").hasClass("hidden")) {
|
||||
$("#wordsInput").focus();
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import {
|
|||
showBackgroundLoader,
|
||||
hideBackgroundLoader,
|
||||
swapElements,
|
||||
accountIconLoading,
|
||||
updateTestModesNotice,
|
||||
focusWords,
|
||||
} from "./dom-util";
|
||||
|
@ -38,3 +37,4 @@ import * as ManualRestart from "./manual-restart-tracker";
|
|||
import Config from "./config";
|
||||
import * as ConfigSet from "./config-set";
|
||||
import * as Focus from "./focus";
|
||||
import * as AccountIcon from "./account-icon";
|
||||
|
|
|
@ -1933,7 +1933,7 @@ function showResult(difficultyFailed = false) {
|
|||
completedEvent.uid = firebase.auth().currentUser.uid;
|
||||
|
||||
//check local pb
|
||||
accountIconLoading(true);
|
||||
AccountIcon.loading(true);
|
||||
let dontShowCrown = false;
|
||||
let pbDiff = 0;
|
||||
DB.getLocalPB(
|
||||
|
@ -2088,7 +2088,7 @@ function showResult(difficultyFailed = false) {
|
|||
obj: completedEvent,
|
||||
})
|
||||
.then((e) => {
|
||||
accountIconLoading(false);
|
||||
AccountIcon.loading(false);
|
||||
if (e.data == null) {
|
||||
Notifications.add(
|
||||
"Unexpected response from the server: " + e.data,
|
||||
|
|
|
@ -23,12 +23,12 @@ async function saveConfigToCookie(noDbCheck = false) {
|
|||
|
||||
async function saveConfigToDB() {
|
||||
if (firebase.auth().currentUser !== null) {
|
||||
accountIconLoading(true);
|
||||
AccountIcon.loading(true);
|
||||
CloudFunctions.saveConfig({
|
||||
uid: firebase.auth().currentUser.uid,
|
||||
obj: Config,
|
||||
}).then((d) => {
|
||||
accountIconLoading(false);
|
||||
AccountIcon.loading(false);
|
||||
if (d.data.returnCode !== 1) {
|
||||
Notifications.add(`Error saving config to DB! ${d.data.message}`, 4000);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue