optional chaining

This commit is contained in:
Miodec 2022-09-27 22:22:38 +02:00
parent afaac1525e
commit ccb0fcdc2e
2 changed files with 7 additions and 7 deletions

View file

@ -327,7 +327,7 @@ export function startTest(): boolean {
UpdateConfig.setChangedBeforeDb(true);
}
if (Auth.currentUser !== null) {
if (Auth?.currentUser) {
AnalyticsController.log("testStarted");
} else {
AnalyticsController.log("testStartedNoLogin");
@ -876,7 +876,7 @@ export async function init(): Promise<void> {
await Funbox.activate();
}
if (Config.quoteLength.includes(-3) && !Auth.currentUser) {
if (Config.quoteLength.includes(-3) && !Auth?.currentUser) {
UpdateConfig.setQuoteLength(-1);
}
@ -1070,7 +1070,7 @@ export async function init(): Promise<void> {
.replace(/_/g, " ")} quotes found`,
0
);
if (Auth.currentUser) {
if (Auth?.currentUser) {
QuoteSubmitPopup.show(false);
}
UpdateConfig.setMode("words");
@ -1615,7 +1615,7 @@ export async function finish(difficultyFailed = false): Promise<void> {
Result.updateTodayTracker();
}
if (Auth.currentUser == null) {
if (!Auth?.currentUser) {
$(".pageTest #result #rateQuoteButton").addClass("hidden");
$(".pageTest #result #reportQuoteButton").addClass("hidden");
AnalyticsController.log("testCompletedNoLogin");
@ -1666,7 +1666,7 @@ export async function finish(difficultyFailed = false): Promise<void> {
TestStats.resetIncomplete();
}
completedEvent.uid = Auth.currentUser?.uid as string;
completedEvent.uid = Auth?.currentUser?.uid as string;
Result.updateRateQuote(TestWords.randomQuote);
AccountButton.loading(true);

View file

@ -264,7 +264,7 @@ export async function screenshot(): Promise<void> {
$("#nocss").removeClass("hidden");
if (revertCookie) $("#cookiePopupWrapper").removeClass("hidden");
if (revealReplay) $("#resultReplay").removeClass("hidden");
if (Auth.currentUser == null) {
if (!Auth?.currentUser) {
$(".pageTest .loginTip").removeClass("hidden");
}
}
@ -279,7 +279,7 @@ export async function screenshot(): Promise<void> {
$(".pageTest .ssWatermark").text(
format(dateNow, "dd MMM yyyy HH:mm") + " | monkeytype.com "
);
if (Auth.currentUser != null) {
if (Auth?.currentUser) {
$(".pageTest .ssWatermark").text(
DB.getSnapshot().name +
" | " +