mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-26 08:47:36 +08:00
added page transition state module
fixes 6 circular dependencies part of #2462
This commit is contained in:
parent
2878fb03e0
commit
3a3558ef17
5 changed files with 23 additions and 17 deletions
|
|
@ -13,6 +13,7 @@ import axiosInstance from "../axios-instance";
|
|||
import * as PSA from "../elements/psa";
|
||||
import * as Focus from "../test/focus";
|
||||
import * as Loader from "../elements/loader";
|
||||
import * as PageTransition from "./../states/page-transition";
|
||||
|
||||
export const gmailProvider = new firebase.auth.GoogleAuthProvider();
|
||||
// const githubProvider = new firebase.auth.GithubAuthProvider();
|
||||
|
|
@ -40,7 +41,7 @@ async function loadUser(user) {
|
|||
`<p class="accountVerificatinNotice" style="text-align:center">Your account is not verified. <a class="sendVerificationEmail">Send the verification email again</a>.`
|
||||
);
|
||||
}
|
||||
PageController.setTransition(false);
|
||||
PageTransition.set(false);
|
||||
AccountButton.update();
|
||||
AccountButton.loading(true);
|
||||
await Account.getDataAndInit();
|
||||
|
|
@ -80,7 +81,7 @@ const authListener = firebase.auth().onAuthStateChanged(async function (user) {
|
|||
if (window.location.pathname == "/account") {
|
||||
window.history.replaceState("", null, "/login");
|
||||
}
|
||||
PageController.setTransition(false);
|
||||
PageTransition.set(false);
|
||||
}
|
||||
if (window.location.pathname == "/login" && user) {
|
||||
PageController.change("account");
|
||||
|
|
|
|||
|
|
@ -7,15 +7,10 @@ import * as PageTest from "./../pages/test";
|
|||
import * as PageAbout from "./../pages/about";
|
||||
import * as PageLogin from "./../pages/login";
|
||||
import * as PageLoading from "./../pages/loading";
|
||||
|
||||
export let transition = true;
|
||||
|
||||
export function setTransition(val) {
|
||||
transition = val;
|
||||
}
|
||||
import * as PageTransition from "./../states/page-transition";
|
||||
|
||||
export function change(page) {
|
||||
if (transition) {
|
||||
if (PageTransition.get()) {
|
||||
console.log(`change page ${page} stopped`);
|
||||
return;
|
||||
}
|
||||
|
|
@ -58,13 +53,13 @@ export function change(page) {
|
|||
ActivePage.set(undefined);
|
||||
$(".page").removeClass("active");
|
||||
previousPage?.beforeHide();
|
||||
setTransition(true);
|
||||
PageTransition.set(true);
|
||||
Misc.swapElements(
|
||||
previousPage.element,
|
||||
nextPage.element,
|
||||
250,
|
||||
() => {
|
||||
setTransition(false);
|
||||
PageTransition.set(false);
|
||||
ActivePage.set(nextPage.name);
|
||||
previousPage?.afterHide();
|
||||
nextPage.element.addClass("active");
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import axiosInstance from "../axios-instance";
|
|||
import * as TodayTracker from "./../test/today-tracker";
|
||||
import * as ActivePage from "../states/active-page";
|
||||
import * as TestActive from "./../states/test-active";
|
||||
import * as PageTransition from "./../states/page-transition";
|
||||
import Page from "./page";
|
||||
|
||||
let filterDebug = false;
|
||||
|
|
@ -243,7 +244,7 @@ export async function getDataAndInit() {
|
|||
TagController.loadActiveFromLocalStorage();
|
||||
ResultTagsPopup.updateButtons();
|
||||
Settings.showAccountSection();
|
||||
PageController.setTransition(false);
|
||||
PageTransition.set(false);
|
||||
console.log("account loading finished");
|
||||
// if (ActivePage.get() == "loading") {
|
||||
// LoadingPage.updateBar(100, true);
|
||||
|
|
|
|||
9
frontend/src/js/states/page-transition.js
Normal file
9
frontend/src/js/states/page-transition.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
let transition = true;
|
||||
|
||||
export function set(val) {
|
||||
transition = val;
|
||||
}
|
||||
|
||||
export function get() {
|
||||
return transition;
|
||||
}
|
||||
|
|
@ -17,7 +17,6 @@ import * as LiveWpm from "./live-wpm";
|
|||
import * as LiveAcc from "./live-acc";
|
||||
import * as LiveBurst from "./live-burst";
|
||||
import * as TimerProgress from "./timer-progress";
|
||||
import * as PageController from "./../controllers/page-controller";
|
||||
import * as QuoteSearchPopup from "../popups/quote-search-popup";
|
||||
import * as QuoteSubmitPopup from "../popups/quote-submit-popup";
|
||||
import * as PbCrown from "./pb-crown";
|
||||
|
|
@ -44,6 +43,7 @@ import * as TestInput from "./test-input";
|
|||
import * as TestWords from "./test-words";
|
||||
import * as TestState from "./test-state";
|
||||
import * as ModesNotice from "./../elements/modes-notice";
|
||||
import * as PageTransition from "./../states/page-transition";
|
||||
|
||||
const objecthash = require("node-object-hash")().hash;
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ export function punctuateWord(previousWord, currentWord, index, maxindex) {
|
|||
}
|
||||
|
||||
export function startTest() {
|
||||
if (PageController.transition) {
|
||||
if (PageTransition.get()) {
|
||||
return false;
|
||||
}
|
||||
if (!Config.dbConfigLoaded) {
|
||||
|
|
@ -392,14 +392,14 @@ export function restart(
|
|||
if (TestUI.resultVisible) {
|
||||
if (
|
||||
Config.randomTheme !== "off" &&
|
||||
!PageController.transition &&
|
||||
!PageTransition.get() &&
|
||||
!Config.customTheme
|
||||
) {
|
||||
ThemeController.randomizeTheme();
|
||||
}
|
||||
}
|
||||
TestUI.setResultVisible(false);
|
||||
PageController.setTransition(true);
|
||||
PageTransition.set(true);
|
||||
TestUI.setTestRestarting(true);
|
||||
el.stop(true, true).animate(
|
||||
{
|
||||
|
|
@ -555,7 +555,7 @@ export function restart(
|
|||
TestUI.focusWords();
|
||||
// ChartController.result.update();
|
||||
ModesNotice.update();
|
||||
PageController.setTransition(false);
|
||||
PageTransition.set(false);
|
||||
// console.log(TestStats.incompleteSeconds);
|
||||
// console.log(TestStats.restartCount);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue