Skip to content

Commit

Permalink
added simple loading template mechanism for music route
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchadwick committed Jun 5, 2024
1 parent a41710e commit 638b7f3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
12 changes: 1 addition & 11 deletions app/components/song-list.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';

export default class SongListComponent extends Component {
@tracked currentlyLoading = false;

@action
async loading(transition) {
this.currentlyLoading = true;

transition.promise.finally(function () {
this.currentlyLoading = false;
});
}
@tracked isLoading = false;
}
5 changes: 4 additions & 1 deletion app/controllers/music.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Controller from '@ember/controller';
import { tracked } from '@glimmer/tracking';

export default class MusicController extends Controller {}
export default class MusicController extends Controller {
@tracked isLoading = false;
}
2 changes: 2 additions & 0 deletions app/routes/music.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import Route from '@ember/routing/route';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';

export default class MusicRoute extends Route {
@service store;
@service headData;
@tracked isLoading = true;

model() {
return this.store.findAll('song');
Expand Down
3 changes: 3 additions & 0 deletions app/templates/music-loading.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="loading-spinner">
{{t "general.loading"}}
</div>
6 changes: 5 additions & 1 deletion app/templates/music.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<h2>{{t "layout.headMusic"}}</h2>
<p>{{t "sections.music.description"}}</p>
<SongList @songs={{@model}} />
{{#if this.isLoading}}
{{t "general.loading"}}
{{else}}
<SongList @songs={{@model}} />
{{/if}}

0 comments on commit 638b7f3

Please sign in to comment.