optional chaining

This commit is contained in:
Miodec 2022-09-27 22:19:13 +02:00
parent 5fcb549d8a
commit 632d615e38
2 changed files with 5 additions and 5 deletions

View file

@ -130,7 +130,7 @@ export async function update(): Promise<void> {
avgAcc = Math.round(avgAcc);
}
if (Auth.currentUser && avgWPM > 0) {
if (Auth?.currentUser && avgWPM > 0) {
const avgWPMText = ["wpm", "both"].includes(Config.showAverage)
? Config.alwaysShowCPM
? `${Math.round(avgWPM * 5)} cpm`

View file

@ -562,7 +562,7 @@ export function hideAccountSection(): void {
export function updateDiscordSection(): void {
//no code and no discord
if (Auth.currentUser == null) {
if (Auth?.currentUser == null) {
$(".pageSettings .section.discordIntegration").addClass("hidden");
} else {
if (DB.getSnapshot() == null) return;
@ -589,7 +589,7 @@ export function updateAuthSections(): void {
$(".pageSettings .section.passwordAuthSettings .button").addClass("hidden");
$(".pageSettings .section.googleAuthSettings .button").addClass("hidden");
const user = Auth.currentUser;
const user = Auth?.currentUser;
if (!user) return;
const passwordProvider = user.providerData.find(
@ -640,7 +640,7 @@ function setActiveFunboxButton(): void {
}
function refreshTagsSettingsSection(): void {
if (Auth.currentUser !== null && DB.getSnapshot() !== null) {
if (Auth?.currentUser && DB.getSnapshot() !== null) {
const tagsEl = $(".pageSettings .section.tags .tagsList").empty();
DB.getSnapshot().tags?.forEach((tag) => {
// let tagPbString = "No PB found";
@ -675,7 +675,7 @@ function refreshTagsSettingsSection(): void {
}
function refreshPresetsSettingsSection(): void {
if (Auth.currentUser !== null && DB.getSnapshot() !== null) {
if (Auth?.currentUser && DB.getSnapshot() !== null) {
const presetsEl = $(".pageSettings .section.presets .presetsList").empty();
DB.getSnapshot().presets?.forEach((preset: MonkeyTypes.Preset) => {
presetsEl.append(`