From e212d5e7c4bfb66753c836e4a5d73cfff6f54790 Mon Sep 17 00:00:00 2001 From: Terncode Date: Tue, 10 Sep 2019 12:28:09 +0200 Subject: [PATCH] Improved code --- src/ts/components/shared/chat-box/chat-box.ts | 4 +-- .../components/shared/chat-log/chat-log.pug | 1 - .../shared/settings-modal/settings-modal.pug | 6 ++--- .../shared/settings-modal/settings-modal.ts | 25 +------------------ 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/ts/components/shared/chat-box/chat-box.ts b/src/ts/components/shared/chat-box/chat-box.ts index df7b8eb..878920a 100644 --- a/src/ts/components/shared/chat-box/chat-box.ts +++ b/src/ts/components/shared/chat-box/chat-box.ts @@ -290,9 +290,9 @@ export class ChatBox implements AfterViewInit, OnDestroy { this.open(); } } - onMouseEnter(event: MouseEvent) { + onMouseEnterEmojiButton(event: MouseEvent) { if (!event.target) return; - const emoji = _.sample(emojis) || emojis[0]; + const emoji = _.sample(emojis)!; this.btnEmoji = emoji.names[0]; } toggleChatType() { diff --git a/src/ts/components/shared/chat-log/chat-log.pug b/src/ts/components/shared/chat-log/chat-log.pug index 6a3b75a..2d1aa0e 100644 --- a/src/ts/components/shared/chat-log/chat-log.pug +++ b/src/ts/components/shared/chat-log/chat-log.pug @@ -26,4 +26,3 @@ button.game-button.chat-log-toggle(#toggleButton (click)="toggle()" title="Toggl path.main-bubble(fill="currentColor" d="M416 192c0-88.4-93.1-160-208-160S0 103.6 0 192c0 34.3 14.1 65.9 38 92-13.4 30.2-35.5 54.2-35.8 54.5-2.2 2.3-2.8 5.7-1.5 8.7S4.8 352 8 352c36.6 0 66.9-12.3 88.7-25 32.2 15.7 70.3 25 111.3 25 114.9 0 208-71.6 208-160z") path(fill="currentColor" d="M538 412c23.9-26 38-57.7 38-92 0-66.9-53.5-124.2-129.3-148.1.9 6.6 1.3 13.3 1.3 20.1 0 105.9-107.7 192-240 192-10.8 0-21.3-.8-31.7-1.9C207.8 439.6 281.8 480 368 480c41 0 79.1-9.2 111.3-25 21.8 12.7 52.1 25 88.7 25 3.2 0 6.1-1.9 7.3-4.8 1.3-2.9.7-6.3-1.5-8.7-.3-.3-22.4-24.2-35.8-54.5z") .whispers-count(#count) - \ No newline at end of file diff --git a/src/ts/components/shared/settings-modal/settings-modal.pug b/src/ts/components/shared/settings-modal/settings-modal.pug index 853c495..7dcf473 100644 --- a/src/ts/components/shared/settings-modal/settings-modal.pug +++ b/src/ts/components/shared/settings-modal/settings-modal.pug @@ -76,9 +76,9 @@ label#chatlog-opacity-label Timestamp div .btn-group.mb-2(btnCheckbox) - button.btn.btn-outline-secondary.d-sm-block([class.active]='off' (click)='switchTimestamp()') None - button.btn.btn-outline-secondary.d-sm-block([class.active]='twelve' (click)='switchTimestamp("12")') 12-hour format - button.btn.btn-outline-secondary.d-sm-block([class.active]='twentyFour' (click)='switchTimestamp("24")') 24-hour format + button.btn.btn-outline-secondary.d-sm-block([class.active]='!browser.timestamp' (click)='switchTimestamp()') None + button.btn.btn-outline-secondary.d-sm-block([class.active]='browser.timestamp === "12"' (click)='switchTimestamp("12")') 12-hour format + button.btn.btn-outline-secondary.d-sm-block([class.active]='browser.timestamp === "24"' (click)='switchTimestamp("24")') 24-hour format small.form-text.text-muted.mt-0 Displays a timestamp in front of chatlog messages .form-group diff --git a/src/ts/components/shared/settings-modal/settings-modal.ts b/src/ts/components/shared/settings-modal/settings-modal.ts index 99e79a3..41ee245 100644 --- a/src/ts/components/shared/settings-modal/settings-modal.ts +++ b/src/ts/components/shared/settings-modal/settings-modal.ts @@ -26,9 +26,7 @@ export class SettingsModal implements OnInit, OnDestroy { readonly graphicsIcon = faImage; readonly exportIcon = faDownload; readonly importIcon = faUpload; - off = false; - twelve = false; - twentyFour = false; + @Output() close = new EventEmitter(); account: AccountSettings = {}; browser: BrowserSettings = {}; @@ -62,7 +60,6 @@ export class SettingsModal implements OnInit, OnDestroy { this.browser = this.settingsService.browser; this.setupDefaults(); this.subscription = this.game.onLeft.subscribe(() => this.cancel()); - this.updateTimestampRadios(); } ngOnDestroy() { this.finishChatlogRange(); @@ -108,26 +105,6 @@ export class SettingsModal implements OnInit, OnDestroy { if (!state) this.browser.timestamp = undefined; else if (state === '12') this.browser.timestamp = '12'; else if (state === '24') this.browser.timestamp = '24'; - this.updateTimestampRadios(); - } - turnOffTimestampRadioButtons() { - this.off = false; - this.twelve = false; - this.twentyFour = false; - } - updateTimestampRadios() { - this.turnOffTimestampRadioButtons(); - switch (this.browser.timestamp) { - case '12': - this.twelve = true; - break; - case '24': - this.twentyFour = true; - break; - default: - this.off = true; - break; - } } updateChatlogRange(range: number | undefined) { document.body.classList.add('translucent-modals');