Skip to content

Commit 8c9c6a8

Browse files
authored
refactor(account settings): use show and hide functions(@Leonabcd123) (monkeytypegame#7241)
### Description Complete monkeytypegame#7219
1 parent 64436ee commit 8c9c6a8

File tree

1 file changed

+26
-58
lines changed

1 file changed

+26
-58
lines changed

frontend/src/ts/pages/account-settings.ts

Lines changed: 26 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -52,82 +52,58 @@ function updateAuthenticationSections(): void {
5252
);
5353

5454
if (passwordProvider) {
55-
pageElement
56-
.qs(".section.passwordAuthSettings #emailPasswordAuth")
57-
?.removeClass("hidden");
58-
pageElement
59-
.qs(".section.passwordAuthSettings #passPasswordAuth")
60-
?.removeClass("hidden");
55+
pageElement.qs(".section.passwordAuthSettings #emailPasswordAuth")?.show();
56+
pageElement.qs(".section.passwordAuthSettings #passPasswordAuth")?.show();
6157
if (googleProvider || githubProvider) {
6258
pageElement
6359
.qs(".section.passwordAuthSettings #removePasswordAuth")
64-
?.removeClass("hidden");
60+
?.show();
6561
}
6662
} else {
67-
pageElement
68-
.qs(".section.passwordAuthSettings #addPasswordAuth")
69-
?.removeClass("hidden");
63+
pageElement.qs(".section.passwordAuthSettings #addPasswordAuth")?.show();
7064
}
7165

7266
if (googleProvider) {
73-
pageElement
74-
.qs(".section.googleAuthSettings #removeGoogleAuth")
75-
?.removeClass("hidden");
67+
pageElement.qs(".section.googleAuthSettings #removeGoogleAuth")?.show();
7668
if (passwordProvider || githubProvider) {
77-
pageElement
78-
.qs(".section.googleAuthSettings #removeGoogleAuth")
79-
?.removeClass("disabled");
69+
pageElement.qs(".section.googleAuthSettings #removeGoogleAuth")?.enable();
8070
} else {
8171
pageElement
8272
.qs(".section.googleAuthSettings #removeGoogleAuth")
83-
?.addClass("disabled");
73+
?.disable();
8474
}
8575
} else {
86-
pageElement
87-
.qs(".section.googleAuthSettings #addGoogleAuth")
88-
?.removeClass("hidden");
76+
pageElement.qs(".section.googleAuthSettings #addGoogleAuth")?.show();
8977
}
9078
if (githubProvider) {
91-
pageElement
92-
.qs(".section.githubAuthSettings #removeGithubAuth")
93-
?.removeClass("hidden");
79+
pageElement.qs(".section.githubAuthSettings #removeGithubAuth")?.show();
9480
if (passwordProvider || googleProvider) {
95-
pageElement
96-
.qs(".section.githubAuthSettings #removeGithubAuth")
97-
?.removeClass("disabled");
81+
pageElement.qs(".section.githubAuthSettings #removeGithubAuth")?.enable();
9882
} else {
9983
pageElement
10084
.qs(".section.githubAuthSettings #removeGithubAuth")
101-
?.addClass("disabled");
85+
?.disable();
10286
}
10387
} else {
104-
pageElement
105-
.qs(".section.githubAuthSettings #addGithubAuth")
106-
?.removeClass("hidden");
88+
pageElement.qs(".section.githubAuthSettings #addGithubAuth")?.show();
10789
}
10890
}
10991

11092
function updateIntegrationSections(): void {
11193
//no code and no discord
11294
if (!isAuthenticated()) {
113-
pageElement.qs(".section.discordIntegration")?.addClass("hidden");
95+
pageElement.qs(".section.discordIntegration")?.hide();
11496
} else {
11597
if (!getSnapshot()) return;
116-
pageElement.qs(".section.discordIntegration")?.removeClass("hidden");
98+
pageElement.qs(".section.discordIntegration")?.show();
11799

118100
if (getSnapshot()?.discordId === undefined) {
119101
//show button
120-
pageElement
121-
.qs(".section.discordIntegration .buttons")
122-
?.removeClass("hidden");
123-
pageElement.qs(".section.discordIntegration .info")?.addClass("hidden");
102+
pageElement.qs(".section.discordIntegration .buttons")?.show();
103+
pageElement.qs(".section.discordIntegration .info")?.hide();
124104
} else {
125-
pageElement
126-
.qs(".section.discordIntegration .buttons")
127-
?.addClass("hidden");
128-
pageElement
129-
.qs(".section.discordIntegration .info")
130-
?.removeClass("hidden");
105+
pageElement.qs(".section.discordIntegration .buttons")?.hide();
106+
pageElement.qs(".section.discordIntegration .info")?.show();
131107
}
132108
}
133109
}
@@ -150,31 +126,23 @@ function updateTabs(): void {
150126
}
151127

152128
function updateAccountSections(): void {
153-
pageElement.qs(".section.optOutOfLeaderboards .optedOut")?.addClass("hidden");
154-
pageElement
155-
.qs(".section.optOutOfLeaderboards .buttons")
156-
?.removeClass("hidden");
157-
pageElement.qs(".section.setStreakHourOffset .info")?.addClass("hidden");
158-
pageElement
159-
.qs(".section.setStreakHourOffset .buttons")
160-
?.removeClass("hidden");
129+
pageElement.qs(".section.optOutOfLeaderboards .optedOut")?.hide();
130+
pageElement.qs(".section.optOutOfLeaderboards .buttons")?.show();
131+
pageElement.qs(".section.setStreakHourOffset .info")?.hide();
132+
pageElement.qs(".section.setStreakHourOffset .buttons")?.show();
161133

162134
const snapshot = getSnapshot();
163135
if (snapshot?.lbOptOut === true) {
164-
pageElement
165-
.qs(".section.optOutOfLeaderboards .optedOut")
166-
?.removeClass("hidden");
167-
pageElement
168-
.qs(".section.optOutOfLeaderboards .buttons")
169-
?.addClass("hidden");
136+
pageElement.qs(".section.optOutOfLeaderboards .optedOut")?.show();
137+
pageElement.qs(".section.optOutOfLeaderboards .buttons")?.hide();
170138
}
171139
if (snapshot?.streakHourOffset !== undefined) {
172-
pageElement.qs(".section.setStreakHourOffset .info")?.removeClass("hidden");
140+
pageElement.qs(".section.setStreakHourOffset .info")?.show();
173141
const sign = snapshot?.streakHourOffset > 0 ? "+" : "";
174142
pageElement
175143
.qs(".section.setStreakHourOffset .info span")
176144
?.setText(sign + snapshot?.streakHourOffset);
177-
pageElement.qs(".section.setStreakHourOffset .buttons")?.addClass("hidden");
145+
pageElement.qs(".section.setStreakHourOffset .buttons")?.hide();
178146
}
179147
}
180148

0 commit comments

Comments
 (0)