Refactor client (#4307)

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Fix bug

* 🎨

* 🎨

* 🎨
This commit is contained in:
syuilo 2019-02-18 09:17:55 +09:00 committed by GitHub
parent efd0368e56
commit ba1492f977
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 738 additions and 1526 deletions

View file

@ -5,7 +5,7 @@
</span>
<div>
<x-notes ref="timeline" :more="null"/>
<x-notes ref="timeline" :make-promise="makePromise" @inited="() => $emit('loaded')"/>
</div>
</x-column>
</template>
@ -27,31 +27,17 @@ export default Vue.extend({
data() {
return {
fetching: true,
faNewspaper
faNewspaper,
makePromise: cursor => this.$root.api('notes/featured', {
limit: 20,
}).then(notes => {
notes.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
return notes;
})
};
},
mounted() {
this.fetch();
},
methods: {
fetch() {
this.fetching = true;
(this.$refs.timeline as any).init(() => new Promise((res, rej) => {
this.$root.api('notes/featured', {
limit: 20,
}).then(notes => {
notes.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
res(notes);
this.fetching = false;
this.$emit('loaded');
}, rej);
}));
},
focus() {
this.$refs.timeline.focus();
}