From 4f883bf4faeb5a1601cf4a011526ec87c3d5bba7 Mon Sep 17 00:00:00 2001 From: Geomitron <22552797+Geomitron@users.noreply.github.com> Date: Tue, 16 Jan 2024 09:26:03 -0600 Subject: [PATCH] Minor bugfixes --- .../chart-sidebar-menu.component.html | 28 +++++++++++++++---- .../chart-sidebar-menu.component.ts | 24 +++++++++------- .../browse/search-bar/search-bar.component.ts | 16 ----------- .../app/core/services/search.service.ts | 10 +++++-- src-shared/UtilFunctions.ts | 8 +++--- 5 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html index e2d3408..9bbd24f 100644 --- a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html +++ b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.html @@ -40,7 +40,17 @@ }
- +
+ More details * +
+ + Please provide more details.
@@ -65,11 +75,19 @@ } Uploaded - - Hash + + + Hash + - - Chart Hash + + + Chart Hash + Google Drive Location diff --git a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts index 738cc28..5e21266 100644 --- a/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts +++ b/src-angular/app/components/browse/chart-sidebar/chart-sidebar-menu/chart-sidebar-menu.component.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@angular/common/http' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' -import { FormControl } from '@angular/forms' +import { FormControl, Validators } from '@angular/forms' import { sortBy } from 'lodash' import { environment } from 'src-angular/environments/environment' @@ -33,7 +33,7 @@ export class ChartSidebarMenutComponent implements OnInit { this.selectedVersion.valueChanges.subscribe(v => this.selectedVersionChanges.emit(v)) this.reportOption = new FormControl(this.reportOptions[0], { nonNullable: true }) - this.reportExtraInfo = new FormControl('', { nonNullable: true }) + this.reportExtraInfo = new FormControl('', { nonNullable: true, validators: [Validators.required] }) } get displayVersions() { @@ -78,13 +78,17 @@ export class ChartSidebarMenutComponent implements OnInit { } report() { - this.http.post(`${environment.apiUrl}/report`, { - chartId: this.selectedVersion.value.chartId, - reason: this.reportOption.value, - extraInfo: this.reportExtraInfo.value, - }).subscribe((response: { message: string }) => { - this.reportMessage = response.message - this.reportSent = true - }) + if (this.reportExtraInfo.valid) { + this.http.post(`${environment.apiUrl}/report`, { + chartId: this.selectedVersion.value.chartId, + reason: this.reportOption.value, + extraInfo: this.reportExtraInfo.value, + }).subscribe((response: { message: string }) => { + this.reportMessage = response.message + this.reportSent = true + }) + } else { + this.reportExtraInfo.markAsTouched() + } } } diff --git a/src-angular/app/components/browse/search-bar/search-bar.component.ts b/src-angular/app/components/browse/search-bar/search-bar.component.ts index ac36530..e88f849 100644 --- a/src-angular/app/components/browse/search-bar/search-bar.component.ts +++ b/src-angular/app/components/browse/search-bar/search-bar.component.ts @@ -87,22 +87,6 @@ export class SearchBarComponent implements OnInit, AfterViewInit { } } - get logoType() { - switch (localStorage.getItem('theme')) { - case 'emerald': return 'emerald' - case 'halloween': return 'halloween' - case 'lemonade': return 'lemonade' - case 'night': return 'night' - case 'synthwave': return 'synthwave' - case 'aqua': return 'orange' - case 'valentine': return 'valentine' - case 'winter': return 'winter' - case 'aren': return 'aren' - case 'froogs': return 'froogs' - default: return 'default' - } - } - get todayDate() { return dayjs().format('YYYY-MM-DD') } diff --git a/src-angular/app/core/services/search.service.ts b/src-angular/app/core/services/search.service.ts index 38cedad..6cd9d4e 100644 --- a/src-angular/app/core/services/search.service.ts +++ b/src-angular/app/core/services/search.service.ts @@ -101,7 +101,9 @@ export class SearchService { if (!nextPage) { // Don't reload results if they are the same - if (this.groupedSongs && xorBy(this.songsResponse.data, response.data, r => r.chartId).length === 0) { + if (this.groupedSongs + && xorBy(this.songsResponse!.data, response.data, r => r.chartId).length === 0 + && this.songsResponse!.found === response.found) { return } else { this.groupedSongs = [] @@ -130,7 +132,7 @@ export class SearchService { this.isDefaultSearch = false let retries = 10 - return this.http.post<{ data: SearchResult['data'] }>(`${environment.apiUrl}/search/advanced`, search).pipe( + return this.http.post<{ data: SearchResult['data']; found: number }>(`${environment.apiUrl}/search/advanced`, search).pipe( catchError((err, caught) => { if (err.status === 400 || retries-- <= 0) { this.searchLoading = false @@ -144,7 +146,9 @@ export class SearchService { this.searchLoading = false // Don't reload results if they are the same - if (this.groupedSongs && xorBy(this.songsResponse.data, response.data, r => r.chartId).length === 0) { + if (this.groupedSongs + && xorBy(this.songsResponse!.data, response.data, r => r.chartId).length === 0 + && this.songsResponse!.found === response.found) { return } else { this.groupedSongs = [] diff --git a/src-shared/UtilFunctions.ts b/src-shared/UtilFunctions.ts index d49f450..73b1050 100644 --- a/src-shared/UtilFunctions.ts +++ b/src-shared/UtilFunctions.ts @@ -118,9 +118,9 @@ export function instrumentToDiff(instrument: Instrument | 'vocals') { * @returns a string representation of `ms` that looks like HH:MM:SS */ export function msToRoughTime(ms: number) { - const seconds = _.round((ms / 1000) % 60) - const minutes = Math.floor((ms / 1000 / 60) % 60) - const hours = Math.floor((ms / 1000 / 60 / 60) % 24) + const seconds = _.floor((ms / 1000) % 60) + const minutes = _.floor((ms / 1000 / 60) % 60) + const hours = _.floor((ms / 1000 / 60 / 60) % 24) return `${hours ? `${hours}:` : ''}${minutes}:${_.padStart(String(seconds), 2, '0')}` } @@ -129,7 +129,7 @@ const allowedTags = [ 'gradient', 'i', 'indent', 'line-height', 'line-indent', 'link', 'lowercase', 'margin', 'mark', 'mspace', 'nobr', 'noparse', 'page', 'pos', 'rotate', 's', 'size', 'smallcaps', 'space', 'sprite', 'strikethrough', 'style', 'sub', 'sup', - 'u', 'uppercase', 'voffset', 'width', + 'u', 'uppercase', 'voffset', 'width', '#', ] const tagPattern = allowedTags.map(tag => `\\b${tag}\\b`).join('|') /**