diff --git a/src/web/app/desktop/tags/crop-window.tag b/src/web/app/desktop/tags/crop-window.tag
index 56845f24a8..c5c1865550 100644
--- a/src/web/app/desktop/tags/crop-window.tag
+++ b/src/web/app/desktop/tags/crop-window.tag
@@ -160,29 +160,35 @@
diff --git a/src/web/app/desktop/tags/follow-button.tag b/src/web/app/desktop/tags/follow-button.tag
index 64055a158f..1877e4a53f 100644
--- a/src/web/app/desktop/tags/follow-button.tag
+++ b/src/web/app/desktop/tags/follow-button.tag
@@ -71,54 +71,70 @@
this.mixin('is-promise');
this.mixin('stream');
- this.user = null
- this.user-promise = if @is-promise this.opts.user then this.opts.user else Promise.resolve this.opts.user
- this.init = true
- this.wait = false
+ this.user = null;
+ this.userPromise = this.isPromise(this.opts.user)
+ ? this.opts.user
+ : Promise.resolve(this.opts.user);
+ this.init = true;
+ this.wait = false;
this.on('mount', () => {
- this.user-promise}).then((user) => {
- this.user = user
- this.init = false
- this.update();
- this.stream.on 'follow' this.on-stream-follow
- this.stream.on 'unfollow' this.on-stream-unfollow
+ this.userPromise.then(user => {
+ this.update({
+ init: false,
+ user: user
+ });
+ this.stream.on('follow', this.onStreamFollow);
+ this.stream.on('unfollow', this.onStreamUnfollow);
+ });
+ });
this.on('unmount', () => {
- this.stream.off 'follow' this.on-stream-follow
- this.stream.off 'unfollow' this.on-stream-unfollow
+ this.stream.off('follow', this.onStreamFollow);
+ this.stream.off('unfollow', this.onStreamUnfollow);
+ });
- this.on-stream-follow = (user) => {
- if user.id == this.user.id
- this.user = user
- this.update();
+ this.onStreamFollow = user => {
+ if (user.id == this.user.id) {
+ this.update({
+ user: user
+ });
+ }
+ };
- this.on-stream-unfollow = (user) => {
- if user.id == this.user.id
- this.user = user
- this.update();
+ this.onStreamUnfollow = user => {
+ if (user.id == this.user.id) {
+ this.update({
+ user: user
+ });
+ }
+ };
this.onclick = () => {
- this.wait = true
- if this.user.is_following
+ this.wait = true;
+ if (this.user.is_following) {
this.api('following/delete', {
user_id: this.user.id
}).then(() => {
- this.user.is_following = false
- .catch (err) ->
- console.error err
+ this.user.is_following = false;
+ }).catch(err => {
+ console.error(err);
}).then(() => {
- this.wait = false
+ this.wait = false;
this.update();
- else
+ });
+ } else {
this.api('following/create', {
user_id: this.user.id
}).then(() => {
- this.user.is_following = true
- .catch (err) ->
- console.error err
+ this.user.is_following = true;
+ }).catch(err => {
+ console.error(err);
}).then(() => {
- this.wait = false
+ this.wait = false;
this.update();
+ });
+ }
+ };
diff --git a/src/web/app/desktop/tags/home.tag b/src/web/app/desktop/tags/home.tag
index 3d0d9d415a..7a148d123c 100644
--- a/src/web/app/desktop/tags/home.tag
+++ b/src/web/app/desktop/tags/home.tag
@@ -59,32 +59,39 @@
diff --git a/src/web/app/desktop/tags/select-file-from-drive-window.tag b/src/web/app/desktop/tags/select-file-from-drive-window.tag
index 45ece233f2..777073583f 100644
--- a/src/web/app/desktop/tags/select-file-from-drive-window.tag
+++ b/src/web/app/desktop/tags/select-file-from-drive-window.tag
@@ -131,31 +131,38 @@
diff --git a/src/web/app/desktop/tags/set-avatar-suggestion.tag b/src/web/app/desktop/tags/set-avatar-suggestion.tag
index ba44a7a33d..335148ea5d 100644
--- a/src/web/app/desktop/tags/set-avatar-suggestion.tag
+++ b/src/web/app/desktop/tags/set-avatar-suggestion.tag
@@ -35,11 +35,13 @@
this.mixin('update-avatar');
this.set = () => {
- @update-avatar this.I
+ this.updateAvatar(this.I);
+ };
- this.close = (e) => {
+ this.close = e => {
e.preventDefault();
e.stopPropagation();
this.unmount();
+ };
diff --git a/src/web/app/desktop/tags/set-banner-suggestion.tag b/src/web/app/desktop/tags/set-banner-suggestion.tag
index fa735e4e42..deddc478cc 100644
--- a/src/web/app/desktop/tags/set-banner-suggestion.tag
+++ b/src/web/app/desktop/tags/set-banner-suggestion.tag
@@ -35,11 +35,13 @@
this.mixin('update-banner');
this.set = () => {
- @update-banner this.I
+ this.updateBanner(this.I);
+ };
- this.close = (e) => {
+ this.close = e => {
e.preventDefault();
e.stopPropagation();
this.unmount();
+ };
diff --git a/src/web/app/desktop/tags/timeline.tag b/src/web/app/desktop/tags/timeline.tag
index f63afabd4a..a589adf5a0 100644
--- a/src/web/app/desktop/tags/timeline.tag
+++ b/src/web/app/desktop/tags/timeline.tag
@@ -3,7 +3,9 @@
{ post._datetext }{ posts[i + 1]._datetext }
- + diff --git a/src/web/app/desktop/tags/user-timeline.tag b/src/web/app/desktop/tags/user-timeline.tag index bc2e1744ef..e8ff3dc054 100644 --- a/src/web/app/desktop/tags/user-timeline.tag +++ b/src/web/app/desktop/tags/user-timeline.tag @@ -50,89 +50,84 @@ this.mixin('is-promise'); this.mixin('get-post-summary'); - this.user = null - this.user-promise = if @is-promise this.opts.user then this.opts.user else Promise.resolve this.opts.user - this.is-loading = true - this.is-empty = false - this.more-loading = false - this.unread-count = 0 - this.mode = 'default' + this.user = null; + this.userPromise = this.isPromise(this.opts.user) + ? this.opts.user + : Promise.resolve(this.opts.user); + this.isLoading = true; + this.isEmpty = false; + this.moreLoading = false; + this.unreadCount = 0; + this.mode = 'default'; this.on('mount', () => { - document.addEventListener 'visibilitychange' @window-onVisibilitychange, false - document.addEventListener 'keydown' this.on-document-keydown - window.addEventListener 'scroll' this.on-scroll + document.addEventListener('keydown', this.onDocumentKeydown); + window.addEventListener('scroll', this.onScroll); - this.user-promise}).then((user) => { - this.user = user - this.update(); + this.userPromise.then(user => { + this.update({ + user: user + }); - @fetch => - this.trigger('loaded'); + this.fetch(() => this.trigger('loaded')); + }); this.on('unmount', () => { - document.removeEventListener 'visibilitychange' @window-onVisibilitychange - document.removeEventListener 'keydown' this.on-document-keydown - window.removeEventListener 'scroll' this.on-scroll + document.removeEventListener('keydown', this.onDocumentKeydown); + window.removeEventListener('scroll', this.onScroll); + }); - this.on-document-keydown = (e) => { - tag = e.target.tag-name.to-lower-case! - if tag != 'input' and tag != 'textarea' - if e.which == 84 // t + this.onDocumentKeydown = e => { + if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') { + if (e.which == 84) { // [t] this.refs.timeline.focus(); + } + } + }; - this.fetch = (cb) => { + this.fetch = cb => { this.api('users/posts', { - user_id: this.user.id - with_replies: this.mode == 'with-replies' - }).then((posts) => { - this.is-loading = false - this.is-empty = posts.length == 0 - this.update(); - this.refs.timeline.set-posts posts - if cb? then cb! - .catch (err) => - console.error err - if cb? then cb! + user_id: this.user.id, + with_replies: this.mode == 'with-replies' + }).then(posts => { + this.update({ + isLoading: false, + isEmpty: posts.length == 0 + }); + this.refs.timeline.setPosts(posts); + if (cb) cb(); + }); + }; this.more = () => { - if @more-loading or @is-loading or this.refs.timeline.posts.length == 0 - return - this.more-loading = true - this.update(); + if (this.moreLoading || this.isLoading || this.refs.timeline.posts.length == 0) return; + this.update({ + moreLoading: true + }); this.api('users/posts', { - user_id: this.user.id - with_replies: this.mode == 'with-replies' - max_id: this.refs.timeline.tail!.id - }).then((posts) => { - this.more-loading = false - this.update(); - this.refs.timeline.prepend-posts posts - .catch (err) => - console.error err + user_id: this.user.id, + with_replies: this.mode == 'with-replies', + max_id: this.refs.timeline.tail().id + }).then(posts => { + this.update({ + moreLoading: false + }); + this.refs.timeline.prependPosts(posts); + }); + }; - this.on-stream-post = (post) => { - this.is-empty = false - this.update(); - this.refs.timeline.add-post post + this.onScroll = () => { + const current = window.scrollY + window.innerHeight; + if (current > document.body.offsetHeight - 16/*遊び*/) { + this.more(); + } + }; - if document.hidden - @unread-count++ - document.title = '(' + @unread-count + ') ' + @get-post-summary post - - this.window-onVisibilitychange = () => { - if !document.hidden - this.unread-count = 0 - document.title = 'Misskey' - - this.on-scroll = () => { - current = window.scrollY + window.inner-height - if current > document.body.offset-height - 16 // 遊び - @more! - - this.set-mode = (mode) => { - @update do + this.setMode = mode => { + this.update({ mode: mode - @fetch! + }); + this.fetch(); + }; diff --git a/src/web/app/desktop/tags/users-list.tag b/src/web/app/desktop/tags/users-list.tag index 2d85cd2ec7..c94d0e228d 100644 --- a/src/web/app/desktop/tags/users-list.tag +++ b/src/web/app/desktop/tags/users-list.tag @@ -1,7 +1,9 @@