From ff4f081e7c932ff8c71866f86c21bcd25416368c Mon Sep 17 00:00:00 2001 From: smuddyx Date: Wed, 10 Jun 2020 17:55:50 +0200 Subject: [PATCH] fix scroll position restore for Firefox --- .../modules/songs/services/text-rendering.service.ts | 11 +++++++---- .../modules/songs/song-list/song-list.component.ts | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/modules/songs/services/text-rendering.service.ts b/src/app/modules/songs/services/text-rendering.service.ts index f298a89..955b6b0 100644 --- a/src/app/modules/songs/services/text-rendering.service.ts +++ b/src/app/modules/songs/services/text-rendering.service.ts @@ -48,7 +48,7 @@ export class TextRenderingService { [SectionType.Chorus]: 0, [SectionType.Verse]: 0, }; - const sections = arrayOfLines.reduce((array, line) => { + return arrayOfLines.reduce((array, line) => { const type = this.getSectionTypeOfLine(line); if (line.match(this.regexSection)) return [...array, { type: type, @@ -58,8 +58,6 @@ export class TextRenderingService { array[array.length - 1].lines.push(this.getLineOfLineText(line)); return array; }, [] as Section[]); - - return sections; } private getLineOfLineText(text: string): Line { @@ -104,7 +102,12 @@ export class TextRenderingService { chords.push(chord); } - return chords; + + const chordCount = chords.reduce((acc: number, cur: Chord) => acc + cur.length, 0); + const lineCount = chordLine.replace(/\s/g, "").length; + + const isChrod = chordCount * 2 > lineCount; + return isChrod ? chords : []; } } diff --git a/src/app/modules/songs/song-list/song-list.component.ts b/src/app/modules/songs/song-list/song-list.component.ts index ac967af..635aa90 100644 --- a/src/app/modules/songs/song-list/song-list.component.ts +++ b/src/app/modules/songs/song-list/song-list.component.ts @@ -46,6 +46,7 @@ export class SongListComponent implements OnInit, OnDestroy { ); setTimeout(() => this.scrollService.restoreScrollPositionFor('songlist'), 100); + setTimeout(() => this.scrollService.restoreScrollPositionFor('songlist'), 300); } public ngOnDestroy(): void {