Skip to content

Commit

Permalink
fix: website sometimes showing signup/login is disabled even though i…
Browse files Browse the repository at this point in the history
…ts not

it was happening if the website loaded faster than the /configuration api call
  • Loading branch information
Miodec committed Mar 14, 2024
1 parent 0ac4706 commit da7e59a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion frontend/src/html/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ <h1 class="text">
</div>
<div class="notificationBubble hidden">5</div>
</button>
<button class="text signInOut hidden" onclick="this.blur();">
<button class="text signInOut" onclick="this.blur();">
<div class="icon">
<i class="fas fa-fw fa-sign-in-alt"></i>
</div>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/html/pages/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div class="preloader hidden">
<i class="fas fa-fw fa-spin fa-circle-notch"></i>
</div>
<div class="disabledNotification">
<div class="disabledNotification hidden">
<p>Login/Signup is disabled.</p>
</div>
<div class="register side hidden">
<div class="register side">
<div class="title">register</div>
<form action="" autocomplete="nope">
<input
Expand Down Expand Up @@ -46,7 +46,7 @@
</button>
</form>
</div>
<div class="login side hidden">
<div class="login side">
<div class="title">login</div>
<button class="text" id="forgotPasswordButton">Forgot password?</button>
<form action="">
Expand Down
9 changes: 0 additions & 9 deletions frontend/src/ts/pages/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { InputIndicator } from "../elements/input-indicator";
import * as Skeleton from "../utils/skeleton";
import * as Misc from "../utils/misc";
import TypoList from "../utils/typo-list";
import * as ServerConfiguration from "../ape/server-configuration";

export function enableSignUpButton(): void {
$(".page.pageLogin .register.side button").prop("disabled", false);
Expand Down Expand Up @@ -354,14 +353,6 @@ export const page = new Page(
},
async () => {
Skeleton.append("pageLogin", "main");
if (ServerConfiguration.get()?.users.signUp) {
enableInputs();
enableSignUpButton();

$(".register").removeClass("hidden");
$(".login").removeClass("hidden");
$(".disabledNotification").addClass("hidden");
}
},
async () => {
//
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/ts/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@ $(document).ready(() => {
if (ConnectionState.get()) {
void PSA.show();
void ServerConfiguration.sync().then(() => {
if (ServerConfiguration.get()?.users.signUp) {
$(".signInOut").removeClass("hidden");
if (!ServerConfiguration.get()?.users.signUp) {
$(".signInOut").addClass("hidden");
$(".register").addClass("hidden");
$(".login").addClass("hidden");
$(".disabledNotification").removeClass("hidden");
}
});
}
Expand Down

0 comments on commit da7e59a

Please sign in to comment.