From a9c2e25d11034e824ede22ddf8567e65e4aa68da Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 11 Mar 2017 19:32:49 +0900 Subject: [PATCH] :v: --- src/web/app/desktop/tags/post-form.tag | 52 ++++++++++++++---- src/web/app/desktop/tags/repost-form.tag | 62 +++++++--------------- src/web/app/desktop/tags/timeline-post.tag | 4 +- 3 files changed, 64 insertions(+), 54 deletions(-) diff --git a/src/web/app/desktop/tags/post-form.tag b/src/web/app/desktop/tags/post-form.tag index bd7a3b94a1..cbd0dc891a 100644 --- a/src/web/app/desktop/tags/post-form.tag +++ b/src/web/app/desktop/tags/post-form.tag @@ -1,6 +1,6 @@
- +
  • @@ -19,8 +19,8 @@

    のこり{ 1000 - refs.text.value.length }文字

    -
    @@ -323,6 +323,29 @@ // https://github.com/riot/riot/issues/2080 if (this.inReplyToPost == '') this.inReplyToPost = null; + this.repost = this.opts.repost; + + // https://github.com/riot/riot/issues/2080 + if (this.repost == '') this.repost = null; + + this.placeholder = this.repost + ? 'この投稿を引用...' + : this.inReplyToPost + ? 'この投稿への返信...' + : 'いまどうしてる?'; + + this.submitText = this.repost + ? 'Repost' + : this.inReplyToPost + ? '返信' + : '投稿'; + + this.draftId = this.repost + ? 'draft-repost-' + this.repost.id + : this.inReplyToPost + ? 'draft-reply-' + this.inReplyToPost.id + : 'draft'; + this.on('mount', () => { this.refs.uploader.on('uploaded', file => { this.addFile(file); @@ -336,7 +359,7 @@ this.autocomplete.attach(); // 書きかけの投稿を復元 - let draft = localStorage.getItem('post-draft'); + let draft = localStorage.getItem(this.draftId); if (draft) { draft = JSON.parse(draft); this.refs.text.value = draft.text; @@ -457,17 +480,26 @@ : undefined; this.api('posts/create', { - text: this.refs.text.value, + text: this.refs.text.value == '' ? undefined : this.refs.text.value, media_ids: files, reply_to_id: this.inReplyToPost ? this.inReplyToPost.id : undefined, + repost_id: this.repost ? this.repost.id : undefined, poll: this.poll ? this.refs.poll.get() : undefined }).then(data => { this.clear(); this.trigger('post'); - localStorage.removeItem('post-draft'); - this.notify(this.inReplyToPost ? '返信しました!' : '投稿しました!'); + localStorage.removeItem(this.draftId); + this.notify(this.repost + ? 'Repostしました!' + : this.inReplyToPost + ? '返信しました!' + : '投稿しました!'); }).catch(err => { - this.notify('投稿できませんでした'); + this.notify(this.repost + ? 'Repostできませんでした' + : this.inReplyToPost + ? '返信できませんでした' + : '投稿できませんでした'); }).then(() => { this.update({ wait: false @@ -485,12 +517,12 @@ this.save = () => { const context = { - text: this.refs.text.value == '' ? undefined : this.refs.text.value, + text: this.refs.text.value, files: this.files, poll: this.poll && this.refs.poll ? this.refs.poll.get() : undefined }; - localStorage.setItem('post-draft', JSON.stringify(context)); + localStorage.setItem(this.draftId, JSON.stringify(context)); }; diff --git a/src/web/app/desktop/tags/repost-form.tag b/src/web/app/desktop/tags/repost-form.tag index e5101d9f2c..2bbed8aca7 100644 --- a/src/web/app/desktop/tags/repost-form.tag +++ b/src/web/app/desktop/tags/repost-form.tag @@ -1,50 +1,21 @@ -
    - -
    - + +
    + 引用する... + + +
    +
    + + +