renamed module, moved one function

This commit is contained in:
Jack 2021-03-30 23:46:23 +01:00
parent 1f54d78fde
commit c08daa493a
5 changed files with 31 additions and 31 deletions

View file

@ -136,8 +136,8 @@ firebase.auth().onAuthStateChanged(function (user) {
`<p class="accountVerificatinNotice" style="text-align:center">Your account is not verified. Click <a onClick="sendVerificationEmail()">here</a> to resend the verification email.`
);
}
updateAccountLoginButton();
AccountIcon.loading(true);
AccountButton.updateAccountLoginButton();
AccountButton.loading(true);
getAccountDataAndInit();
var displayName = user.displayName;
// var email = user.email;
@ -249,7 +249,7 @@ function getAccountDataAndInit() {
}
if (!Config.changedBeforeDb) {
if (Config.cookieConfig === null) {
AccountIcon.loading(false);
AccountButton.loading(false);
UpdateConfig.apply(DB.getSnapshot().config);
Settings.update();
UpdateConfig.saveToCookie(true);
@ -290,7 +290,7 @@ function getAccountDataAndInit() {
// });
// if (configsDifferent) {
// console.log("applying config from db");
// AccountIcon.loading(false);
// AccountButton.loading(false);
// config = DB.getSnapshot().config;
// applyConfig(config);
// Settings.update();
@ -300,7 +300,7 @@ function getAccountDataAndInit() {
}
UpdateConfig.setDbConfigLoaded(true);
} else {
AccountIcon.loading(false);
AccountButton.loading(false);
}
if (Config.paceCaret === "pb" || Config.paceCaret === "average") {
if (!TestLogic.active) {
@ -314,7 +314,7 @@ function getAccountDataAndInit() {
changePage("account");
}
ThemePicker.refreshButtons();
AccountIcon.loading(false);
AccountButton.loading(false);
ResultFilters.updateTags();
CommandlineLists.updateTagCommands();
TagController.loadActiveFromCookie();
@ -322,7 +322,7 @@ function getAccountDataAndInit() {
Settings.showAccountSection();
})
.catch((e) => {
AccountIcon.loading(false);
AccountButton.loading(false);
console.error(e);
Notifications.add(
"Error downloading user data. Client likely could not connect to the backend - refresh to try again. If error persists try clearing your cache and website data or contact Miodec.",
@ -1051,22 +1051,6 @@ function refreshGlobalStats() {
}
}
function updateAccountLoginButton() {
if (firebase.auth().currentUser != null) {
UI.swapElements(
$("#menu .icon-button.login"),
$("#menu .icon-button.account"),
250
);
} else {
UI.swapElements(
$("#menu .icon-button.account"),
$("#menu .icon-button.login"),
250
);
}
}
let totalSecondsFiltered = 0;
function refreshAccountPage() {

View file

@ -1,5 +1,5 @@
import { loadTags } from "./result-filters";
import * as AccountIcon from "./account-icon";
import * as AccountButton from "./account-icon";
import * as CloudFunctions from "./cloud-functions";
import * as Notifications from "./notifications";
@ -453,12 +453,12 @@ export function updateLbMemory(mode, mode2, type, value) {
export async function saveConfig(config) {
if (firebase.auth().currentUser !== null) {
AccountIcon.loading(true);
AccountButton.loading(true);
CloudFunctions.saveConfig({
uid: firebase.auth().currentUser.uid,
obj: config,
}).then((d) => {
AccountIcon.loading(false);
AccountButton.loading(false);
if (d.data.returnCode !== 1) {
Notifications.add(`Error saving config to DB! ${d.data.message}`, 4000);
}

View file

@ -9,3 +9,19 @@ export function loading(truefalse) {
$("#top #menu .account").css("opacity", 1).css("pointer-events", "auto");
}
}
export function update() {
if (firebase.auth().currentUser != null) {
UI.swapElements(
$("#menu .icon-button.login"),
$("#menu .icon-button.account"),
250
);
} else {
UI.swapElements(
$("#menu .icon-button.account"),
$("#menu .icon-button.login"),
250
);
}
}

View file

@ -24,7 +24,7 @@ import * as Caret from "./caret";
import * as ManualRestart from "./manual-restart-tracker";
import Config, * as UpdateConfig from "./config";
import * as Focus from "./focus";
import * as AccountIcon from "./account-icon";
import * as AccountButton from "./account-icon";
import * as TestUI from "./test-ui";
import * as Keymap from "./keymap";
import "./caps-warning";

View file

@ -22,7 +22,7 @@ import * as QuoteSearchPopup from "./quote-search-popup";
import * as PbCrown from "./pb-crown";
import * as TestTimer from "./test-timer";
import * as OutOfFocus from "./out-of-focus";
import * as AccountIcon from "./account-icon";
import * as AccountButton from "./account-icon";
import * as DB from "./db";
import * as ThemeColors from "./theme-colors";
import * as CloudFunctions from "./cloud-functions";
@ -1320,7 +1320,7 @@ export function finish(difficultyFailed = false) {
if (firebase.auth().currentUser != null) {
completedEvent.uid = firebase.auth().currentUser.uid;
//check local pb
AccountIcon.loading(true);
AccountButton.loading(true);
let dontShowCrown = false;
let pbDiff = 0;
DB.getLocalPB(
@ -1480,7 +1480,7 @@ export function finish(difficultyFailed = false) {
obj: completedEvent,
})
.then((e) => {
AccountIcon.loading(false);
AccountButton.loading(false);
if (e.data == null) {
Notifications.add(
"Unexpected response from the server: " + e.data,
@ -1583,7 +1583,7 @@ export function finish(difficultyFailed = false) {
}
})
.catch((e) => {
AccountIcon.loading(false);
AccountButton.loading(false);
console.error(e);
Notifications.add("Could not save result. " + e, -1);
});