From 1e163719581c9e1d219da46c8b6369ca5c217646 Mon Sep 17 00:00:00 2001 From: Geomitron <22552797+Geomitron@users.noreply.github.com> Date: Sun, 9 Feb 2020 23:49:23 -0500 Subject: [PATCH] StatusBar and Sidebar views update correctly --- .../components/browse/browse.component.html | 4 +-- src/app/components/browse/browse.component.ts | 18 ++++++++--- .../downloads-modal.component.ts | 6 ++-- .../status-bar/status-bar.component.html | 6 ++-- .../browse/status-bar/status-bar.component.ts | 15 ++++++++-- src/app/core/services/download.service.ts | 30 ++++++++++++++++++- 6 files changed, 63 insertions(+), 16 deletions(-) diff --git a/src/app/components/browse/browse.component.html b/src/app/components/browse/browse.component.html index be64f10..7707282 100644 --- a/src/app/components/browse/browse.component.html +++ b/src/app/components/browse/browse.component.html @@ -1,4 +1,4 @@ - +
@@ -9,4 +9,4 @@
- \ No newline at end of file + \ No newline at end of file diff --git a/src/app/components/browse/browse.component.ts b/src/app/components/browse/browse.component.ts index ede21af..695f1e6 100644 --- a/src/app/components/browse/browse.component.ts +++ b/src/app/components/browse/browse.component.ts @@ -1,15 +1,25 @@ -import { Component, OnInit } from '@angular/core' +import { Component, ViewChild } from '@angular/core' +import { ChartSidebarComponent } from './chart-sidebar/chart-sidebar.component' +import { StatusBarComponent } from './status-bar/status-bar.component' +import { SongResult } from 'src/electron/shared/interfaces/search.interface' +import { ResultTableComponent } from './result-table/result-table.component' @Component({ selector: 'app-browse', templateUrl: './browse.component.html', styleUrls: ['./browse.component.scss'] }) -export class BrowseComponent implements OnInit { +export class BrowseComponent { + + @ViewChild('resultTable', { static: true }) resultTable: ResultTableComponent + @ViewChild('chartSidebar', { static: true }) chartSidebar: ChartSidebarComponent + @ViewChild('statusBar', { static: true }) statusBar: StatusBarComponent constructor() { } - ngOnInit() { - console.log('Browse component loaded.') + onResultsUpdated(results: SongResult[]) { + this.resultTable.results = results + this.chartSidebar.selectedVersion = undefined + this.statusBar.resultCount = results.length } } \ No newline at end of file diff --git a/src/app/components/browse/status-bar/downloads-modal/downloads-modal.component.ts b/src/app/components/browse/status-bar/downloads-modal/downloads-modal.component.ts index ec83c07..b29c292 100644 --- a/src/app/components/browse/status-bar/downloads-modal/downloads-modal.component.ts +++ b/src/app/components/browse/status-bar/downloads-modal/downloads-modal.component.ts @@ -1,7 +1,6 @@ import { Component, ChangeDetectorRef } from '@angular/core' import { Download } from '../../../../../electron/shared/interfaces/download.interface' import { DownloadService } from '../../../../core/services/download.service' -import * as _ from 'underscore' @Component({ selector: 'app-downloads-modal', @@ -12,8 +11,7 @@ export class DownloadsModalComponent { downloads: Download[] = [] - constructor(downloadService: DownloadService, private ref: ChangeDetectorRef) { - const detectChanges = _.throttle(() => this.ref.detectChanges(), 30) + constructor(downloadService: DownloadService, ref: ChangeDetectorRef) { downloadService.onDownloadUpdated(download => { const index = this.downloads.findIndex(thisDownload => thisDownload.versionID == download.versionID) if (index == -1) { @@ -21,7 +19,7 @@ export class DownloadsModalComponent { } else { this.downloads[index] = download } - detectChanges() + ref.detectChanges() }) } diff --git a/src/app/components/browse/status-bar/status-bar.component.html b/src/app/components/browse/status-bar/status-bar.component.html index 8eb573c..7aa4b20 100644 --- a/src/app/components/browse/status-bar/status-bar.component.html +++ b/src/app/components/browse/status-bar/status-bar.component.html @@ -1,9 +1,9 @@