summaryrefslogtreecommitdiff
path: root/src/web/app/mobile
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-02-21 11:44:53 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-02-21 11:44:53 +0900
commit3ea73a888d0bced98e0e92a8d92110d5b2fe46fd (patch)
treef810889951dc78be8fbc4f6bae92f3518b06a8e6 /src/web/app/mobile
parentwip (diff)
downloadmisskey-3ea73a888d0bced98e0e92a8d92110d5b2fe46fd.tar.gz
misskey-3ea73a888d0bced98e0e92a8d92110d5b2fe46fd.tar.bz2
misskey-3ea73a888d0bced98e0e92a8d92110d5b2fe46fd.zip
wip
Diffstat (limited to 'src/web/app/mobile')
-rw-r--r--src/web/app/mobile/tags/home-timeline.tag48
-rw-r--r--src/web/app/mobile/tags/timeline.tag67
-rw-r--r--src/web/app/mobile/tags/ui-header.tag14
3 files changed, 76 insertions, 53 deletions
diff --git a/src/web/app/mobile/tags/home-timeline.tag b/src/web/app/mobile/tags/home-timeline.tag
index 0d617c841b..2cb051f32a 100644
--- a/src/web/app/mobile/tags/home-timeline.tag
+++ b/src/web/app/mobile/tags/home-timeline.tag
@@ -3,41 +3,49 @@
<style>
:scope
display block
-
</style>
<script>
this.mixin('api');
this.mixin('stream');
- this.init = new Promise (res, rej) =>
- this.api 'posts/timeline'
- }).then((posts) => {
- res posts
+ this.init = new Promise((res, rej) => {
+ this.api('posts/timeline').then(posts => {
+ res(posts);
this.trigger('loaded');
+ });
+ });
this.on('mount', () => {
- this.stream.on 'post' this.on-stream-post
- this.stream.on 'follow' this.on-stream-follow
- this.stream.on 'unfollow' this.on-stream-unfollow
+ this.stream.on('post', this.onStreamPost);
+ this.stream.on('follow', this.onStreamFollow);
+ this.stream.on('unfollow', this.onStreamUnfollow);
+ });
this.on('unmount', () => {
- this.stream.off 'post' this.on-stream-post
- this.stream.off 'follow' this.on-stream-follow
- this.stream.off 'unfollow' this.on-stream-unfollow
+ this.stream.off('post', this.onStreamPost);
+ this.stream.off('follow', this.onStreamFollow);
+ this.stream.off('unfollow', this.onStreamUnfollow);
+ });
this.more = () => {
this.api('posts/timeline', {
- max_id: this.refs.timeline.tail!.id
+ max_id: this.refs.timeline.tail().id
+ });
+ };
- this.on-stream-post = (post) => {
- this.is-empty = false
- this.update();
- this.refs.timeline.add-post post
+ this.onStreamPost = post => {
+ this.update({
+ isEmpty: false
+ });
+ this.refs.timeline.addPost(post);
+ };
- this.on-stream-follow = () => {
- @fetch!
+ this.onStreamFollow = () => {
+ this.fetch();
+ };
- this.on-stream-unfollow = () => {
- @fetch!
+ this.onStreamUnfollow = () => {
+ this.fetch();
+ };
</script>
</mk-home-timeline>
diff --git a/src/web/app/mobile/tags/timeline.tag b/src/web/app/mobile/tags/timeline.tag
index 06571e40e5..421917d834 100644
--- a/src/web/app/mobile/tags/timeline.tag
+++ b/src/web/app/mobile/tags/timeline.tag
@@ -74,45 +74,58 @@
</style>
<script>
- this.posts = []
- this.init = true
- this.fetching = false
- this.can-fetch-more = true
+ this.posts = [];
+ this.init = true;
+ this.fetching = false;
+ this.canFetchMore = true;
this.on('mount', () => {
- this.opts.init}).then((posts) => {
- this.init = false
- @set-posts posts
+ this.opts.init.then(posts => {
+ this.init = false;
+ this.setPosts(posts);
+ });
+ });
this.on('update', () => {
- this.posts.forEach (post) =>
- date = (new Date post.created_at).getDate()
- month = (new Date post.created_at).getMonth() + 1
- post._date = date
- post._datetext = month + '月 ' + date + '日'
+ this.posts.forEach(post => {
+ const date = new Date(post.created_at).getDate();
+ const month = new Date(post.created_at).getMonth() + 1;
+ post._date = date;
+ post._datetext = `${month}月 ${date}日`;
+ });
+ });
this.more = () => {
- if @init or @fetching or this.posts.length == 0 then return
- this.fetching = true
- this.update();
- this.opts.more!}).then((posts) => {
- this.fetching = false
- this.prepend-posts posts
+ if (this.init || this.fetching || this.posts.length == 0) return;
+ this.update({
+ fetching: true
+ });
+ this.opts.more().then(posts => {
+ this.fetching = false;
+ this.prependPosts(posts);
+ });
+ };
- this.set-posts = (posts) => {
- this.posts = posts
- this.update();
+ this.setPosts = posts => {
+ this.update({
+ posts: posts
+ });
+ };
- this.prepend-posts = (posts) => {
- posts.forEach (post) =>
- this.posts.push post
+ this.prependPosts = posts => {
+ posts.forEach(post => {
+ this.posts.push(post);
this.update();
+ });
+ }
- this.add-post = (post) => {
- this.posts.unshift post
+ this.addPost = post => {
+ this.posts.unshift(post);
this.update();
+ };
this.tail = () => {
- this.posts[this.posts.length - 1]
+ return this.posts[this.posts.length - 1];
+ };
</script>
</mk-timeline>
diff --git a/src/web/app/mobile/tags/ui-header.tag b/src/web/app/mobile/tags/ui-header.tag
index 5cf2560d54..405db1897f 100644
--- a/src/web/app/mobile/tags/ui-header.tag
+++ b/src/web/app/mobile/tags/ui-header.tag
@@ -89,16 +89,18 @@
</style>
<script>
this.mixin('ui');
- this.mixin('openPostForm');
+ this.mixin('open-post-form');
this.on('mount', () => {
- this.opts.ready!
+ this.opts.ready();
+ });
- this.ui.on('title', (title) => {
- if this.refs.title?
- this.refs.title.innerHTML = title
+ this.ui.on('title', title => {
+ if (this.refs.title) this.refs.title.innerHTML = title;
+ });
this.post = () => {
- this.openPostForm!
+ this.openPostForm();
+ };
</script>
</mk-ui-header>