Skip to content

Commit b8d9726

Browse files
committed
Auto merge of #2457 - Turbo87:index-loading, r=locks
index: Replace loading spinner with list item placeholders #1937 changed the data loading code of the `index` route to load the summary data in the `model()` hook again. That is fine when using fastboot, but without fastboot it is currently resulting in an ugly loading spinner page before the real page content gets rendered. This PR replaces the loading page with rendering the real page directly and showing placeholders until the real data is available. The new approach is still compatible with fastboot due to the use of `deferReadiness()`. ![loading](https://user-images.githubusercontent.com/141300/80317190-98050780-8802-11ea-8596-8d9f9ee05545.gif) r? @locks
2 parents 53ff1b6 + 10c5e9b commit b8d9726

File tree

14 files changed

+228
-101
lines changed

14 files changed

+228
-101
lines changed

app/components/category-list.hbs

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/components/crate-list-name-only.hbs

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/components/crate-list-newest.hbs

Lines changed: 0 additions & 11 deletions
This file was deleted.

app/components/front-page-list.hbs

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/components/front-page-list.module.css

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
<li>
2-
<LinkTo @route={{@route}} @model={{@model}} local-class="link" ...attributes>
3-
<div local-class="left">
4-
<div local-class="title">{{@title}}</div>
5-
{{#if @subtitle}}<div local-class="subtitle">{{@subtitle}}</div>{{/if}}
6-
</div>
7-
{{svg-jar "chevron-right" local-class="right"}}
8-
</LinkTo>
9-
</li>
1+
<LinkTo @route={{@route}} @model={{@model}} local-class="link" ...attributes>
2+
<div local-class="left">
3+
<div local-class="title">{{@title}}</div>
4+
{{#if @subtitle}}<div local-class="subtitle">{{@subtitle}}</div>{{/if}}
5+
</div>
6+
{{svg-jar "chevron-right" local-class="right"}}
7+
</LinkTo>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div local-class="link" ...attributes>
2+
<div local-class="left">
3+
<div local-class="title"></div>
4+
{{#if @withSubtitle}}<div local-class="subtitle"></div>{{/if}}
5+
</div>
6+
{{svg-jar "chevron-right" local-class="right"}}
7+
</div>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.link {
2+
display: flex;
3+
align-items: center;
4+
width: 100%;
5+
min-height: 60px;
6+
margin: 8px 0;
7+
padding: 0 10px;
8+
background-color: var(--main-bg-dark);
9+
}
10+
11+
.left {
12+
flex-grow: 1;
13+
width: 0;
14+
}
15+
16+
.title {
17+
height: 16px;
18+
width: 150px;
19+
border-radius: 8px;
20+
background: rgb(118, 131, 138);
21+
opacity: 0.25;
22+
}
23+
24+
.subtitle {
25+
height: 13px;
26+
width: 90px;
27+
margin-top: 4px;
28+
border-radius: 6.5px;
29+
background: rgb(118, 131, 138);
30+
opacity: 0.2;
31+
}
32+
33+
.right {
34+
flex-shrink: 0;
35+
height: 16px;
36+
width: auto;
37+
margin-left: 10px;
38+
color: rgb(118, 131, 138);
39+
}

app/components/keyword-list.hbs

Lines changed: 0 additions & 10 deletions
This file was deleted.

app/controllers/index.js

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
import Controller from '@ember/controller';
2+
import { computed } from '@ember/object';
3+
import { readOnly } from '@ember/object/computed';
4+
import { inject as service } from '@ember/service';
5+
6+
import { task } from 'ember-concurrency';
27

38
export default Controller.extend({
4-
hasData: true,
9+
fetcher: service(),
10+
11+
model: readOnly('dataTask.lastSuccessful.value'),
12+
13+
hasData: computed('dataTask.{lastSuccessful,isRunning}', function () {
14+
return this.get('dataTask.lastSuccessful') || !this.get('dataTask.isRunning');
15+
}),
16+
17+
dataTask: task(function* () {
18+
let data = yield this.fetcher.ajax('/api/v1/summary');
19+
20+
addCrates(this.store, data.new_crates);
21+
addCrates(this.store, data.most_downloaded);
22+
addCrates(this.store, data.just_updated);
23+
addCrates(this.store, data.most_recently_downloaded);
24+
25+
return data;
26+
}).drop(),
527
});
28+
29+
function addCrates(store, crates) {
30+
for (let i = 0; i < crates.length; i++) {
31+
crates[i] = store.push(store.normalize('crate', crates[i]));
32+
}
33+
}

0 commit comments

Comments
 (0)