mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-11 13:57:28 +08:00
refactor(sign in out button): move dom modifying code to the element file
This commit is contained in:
parent
8b4b24f0b1
commit
aaadad0812
3 changed files with 8 additions and 10 deletions
|
|
@ -123,8 +123,7 @@ async function getDataAndInit(): Promise<boolean> {
|
|||
}
|
||||
LoadingPage.updateText("Applying settings...");
|
||||
const snapshot = DB.getSnapshot() as MonkeyTypes.Snapshot;
|
||||
AccountButton.updateName(snapshot.name);
|
||||
AccountButton.updateFlags(snapshot);
|
||||
SignInOutButton.update();
|
||||
showFavoriteQuoteLength();
|
||||
|
||||
ResultFilters.loadTags(snapshot.tags);
|
||||
|
|
@ -205,10 +204,6 @@ export async function loadUser(user: UserType): Promise<void> {
|
|||
// var providerData = user.providerData;
|
||||
LoginPage.hidePreloader();
|
||||
|
||||
$("header .signInOut .icon").html(
|
||||
`<i class="fas fa-fw fa-sign-out-alt"></i>`
|
||||
);
|
||||
|
||||
// showFavouriteThemesAtTheTop();
|
||||
|
||||
if (TestLogic.notSignedInLastResult !== null) {
|
||||
|
|
@ -468,10 +463,9 @@ export function signOut(): void {
|
|||
duration: 2,
|
||||
});
|
||||
Settings.hideAccountSection();
|
||||
void AccountButton.update();
|
||||
SignInOutButton.update();
|
||||
navigate("/login");
|
||||
DB.setSnapshot(undefined);
|
||||
$("header .signInOut .icon").html(`<i class="far fa-fw fa-user"></i>`);
|
||||
setTimeout(() => {
|
||||
hideFavoriteQuoteLength();
|
||||
}, 125);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { Auth, isAuthenticated } from "../firebase";
|
||||
|
||||
const el = $("header .signInOut");
|
||||
|
||||
export function update(): void {
|
||||
|
|
@ -15,3 +14,7 @@ export function update(): void {
|
|||
el.find(".icon").html(`<i class="far fa-fw fa-user"></i>`);
|
||||
}
|
||||
}
|
||||
|
||||
export function hide(): void {
|
||||
el.addClass("hidden");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import * as MerchBanner from "./elements/merch-banner";
|
|||
import * as CookiesModal from "./modals/cookies";
|
||||
import * as ConnectionState from "./states/connection";
|
||||
import * as FunboxList from "./test/funbox/funbox-list";
|
||||
import * as SignInOutButton from "./elements/sign-in-out-button";
|
||||
//@ts-expect-error
|
||||
import Konami from "konami";
|
||||
import * as ServerConfiguration from "./ape/server-configuration";
|
||||
|
|
@ -33,7 +34,7 @@ $((): void => {
|
|||
if (ConnectionState.get()) {
|
||||
void ServerConfiguration.sync().then(() => {
|
||||
if (!ServerConfiguration.get()?.users.signUp) {
|
||||
$(".signInOut").addClass("hidden");
|
||||
SignInOutButton.hide();
|
||||
$(".register").addClass("hidden");
|
||||
$(".login").addClass("hidden");
|
||||
$(".disabledNotification").removeClass("hidden");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue