diff --git a/.run/start.run.xml b/.run/start.run.xml
new file mode 100644
index 0000000..b846640
--- /dev/null
+++ b/.run/start.run.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/app.component.ts b/src/app/app.component.ts
index f5159c1..b92e72b 100644
--- a/src/app/app.component.ts
+++ b/src/app/app.component.ts
@@ -21,7 +21,7 @@ export class AppComponent implements OnInit {
public static hideLoader: () => void = () => document.querySelector('#load-bg')?.classList.add('hidden');
public ngOnInit(): void {
- setTimeout(() => AppComponent.hideLoader(), 2000);
+ setTimeout(() => AppComponent.hideLoader(), 1000);
}
public onScoll($event: {srcElement: {scrollTop: number}}): void {
diff --git a/src/app/modules/songs/services/song-list.resolver.ts b/src/app/modules/songs/services/song-list.resolver.ts
new file mode 100644
index 0000000..c366e14
--- /dev/null
+++ b/src/app/modules/songs/services/song-list.resolver.ts
@@ -0,0 +1,17 @@
+import {Injectable} from '@angular/core';
+import {Resolve} from '@angular/router';
+import {Observable} from 'rxjs';
+import {SongService} from './song.service';
+import {Song} from './song';
+import {filter} from 'rxjs/operators';
+
+@Injectable({
+ providedIn: 'root',
+})
+export class SongListResolver implements Resolve {
+ public constructor(private songService: SongService) {}
+
+ public resolve(): Observable {
+ return this.songService.list$().pipe(filter(_ => _.length > 0));
+ }
+}
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 f00a95b..99c6e9d 100644
--- a/src/app/modules/songs/song-list/song-list.component.ts
+++ b/src/app/modules/songs/song-list/song-list.component.ts
@@ -20,7 +20,10 @@ import {faBalanceScaleRight, faCheck, faPencilRuler} from '@fortawesome/free-sol
export class SongListComponent implements OnInit, OnDestroy {
public songs$: Observable | null = combineLatest([
this.activatedRoute.queryParams.pipe(map(_ => _ as FilterValues)),
- this.songService.list$().pipe(map(songs => songs.sort((a, b) => a.number - b.number))),
+ this.activatedRoute.data.pipe(
+ map(data => data.songList as Song[]),
+ map(songs => songs.sort((a, b) => a.number - b.number))
+ ),
]).pipe(
map(_ => {
const songs = _[1];
diff --git a/src/app/modules/songs/songs-routing.module.ts b/src/app/modules/songs/songs-routing.module.ts
index 30dc1cf..b77d7bc 100644
--- a/src/app/modules/songs/songs-routing.module.ts
+++ b/src/app/modules/songs/songs-routing.module.ts
@@ -5,11 +5,13 @@ import {SongListComponent} from './song-list/song-list.component';
import {EditComponent} from './song/edit/edit.component';
import {NewComponent} from './song/new/new.component';
import {EditSongGuard} from './song/edit/edit-song.guard';
+import {SongListResolver} from './services/song-list.resolver';
const routes: Routes = [
{
path: '',
component: SongListComponent,
+ resolve: {songList: SongListResolver},
pathMatch: 'full',
},
{