From 72877b5c06dd46f7334029664175fabd4e7e16ab Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Wed, 2 Nov 2016 18:38:30 +0100
Subject: CSS fixes.

---
 src/components/status/status.vue | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'src/components/status/status.vue')

diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index 4d8700d5..685ec244 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -60,4 +60,8 @@
          word-break: break-all;
      }
  }
+
+ .status-actions {
+     padding-top: 5px;
+ }
 </style>
-- 
cgit v1.2.3-70-g09d2


From 7e2c52b12cf6883f32716230b0fdcdad7a26632b Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Thu, 3 Nov 2016 16:59:27 +0100
Subject: Add replies.

---
 src/components/post_status_form/post_status_form.js | 10 +++++++---
 src/components/status/status.js                     | 12 +++++++++++-
 src/components/status/status.vue                    | 11 +++++++----
 3 files changed, 25 insertions(+), 8 deletions(-)

(limited to 'src/components/status/status.vue')

diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index 596c9f58..0944d841 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -1,16 +1,20 @@
 import statusPoster from '../../services/status_poster/status_poster.service.js'
 
 const PostStatusForm = {
-  data() {
+  props: [
+    'replyTo'
+  ],
+  data () {
     return {
       newStatus: { }
     }
   },
   methods: {
-    postStatus(newStatus) {
+    postStatus (newStatus) {
       statusPoster.postStatus({
         status: newStatus.status,
-        store: this.$store
+        store: this.$store,
+        inReplyToStatusId: this.replyTo
       })
       this.newStatus = { }
     }
diff --git a/src/components/status/status.js b/src/components/status/status.js
index f3816daa..2e6565e8 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -1,8 +1,12 @@
 import Attachment from '../attachment/attachment.vue'
 import FavoriteButton from '../favorite_button/favorite_button.vue'
+import PostStatusForm from '../post_status_form/post_status_form.vue'
 
 const Status = {
   props: [ 'statusoid' ],
+  data: () => ({
+    replying: false
+  }),
   computed: {
     retweet () { return !!this.statusoid.retweeted_status },
     retweeter () { return this.statusoid.user.name },
@@ -16,7 +20,13 @@ const Status = {
   },
   components: {
     Attachment,
-    FavoriteButton
+    FavoriteButton,
+    PostStatusForm
+  },
+  methods: {
+    toggleReplying () {
+      this.replying = !this.replying
+    }
   }
 }
 
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index 685ec244..ab827325 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -2,7 +2,7 @@
   <div class="status-el">
     <div v-if="retweet" class="media container retweet-info">
       <div class="media-left">
-        <i class='fa fa-retweet'></i>
+        <i class='fa icon-retweet'></i>
       </div>
       <div class="media-body">
         Retweeted by {{retweeter}}
@@ -34,8 +34,10 @@
 
         <div>
           <div class='status-actions'>
-            <div ng-click="toggleReplying()">
-              <i class='fa icon-reply'></i>
+            <div>
+              <a href="#" v-on:click.prevent="toggleReplying()">
+                <i class='fa icon-reply'></i>
+              </a>
             </div>
             <div>
               <i class='fa icon-retweet'></i>
@@ -43,7 +45,7 @@
             <favorite-button :status=status></favorite-button>
           </div>
 
-          <!-- <post-status-form ng-if="replying" toggle="toggleReplying" reply-to-status="status" reply-to="{{status.id}}"></post-status-form> -->
+          <post-status-form v-if="replying" :reply-to="status.id"></post-status-form>
         </div>
       </div>
     </div>
@@ -55,6 +57,7 @@
 <style lang="scss">
  .status-el {
      word-wrap: break-word;
+     word-break: break-word;
 
      a {
          word-break: break-all;
-- 
cgit v1.2.3-70-g09d2


From 9ff8bf4c143f849635d64f5d0344ff999908fe34 Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Thu, 3 Nov 2016 17:17:32 +0100
Subject: Make mention strings work.

---
 .../post_status_form/post_status_form.js           | 32 ++++++++++++++++++++--
 src/components/status/status.vue                   |  2 +-
 2 files changed, 31 insertions(+), 3 deletions(-)

(limited to 'src/components/status/status.vue')

diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index 0944d841..0d4d87f2 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -1,12 +1,40 @@
 import statusPoster from '../../services/status_poster/status_poster.service.js'
+import { reject, map, uniqBy } from 'lodash';
+
+const buildMentionsString = ({user, attentions}, currentUser) => {
+
+  let allAttentions = [...attentions]
+
+  allAttentions.unshift(user)
+
+  allAttentions = uniqBy(allAttentions, 'id')
+  allAttentions = reject(allAttentions, {id: currentUser.id})
+
+  let mentions = map(allAttentions, (attention) => {
+    return `@${attention.screen_name}`
+  })
+
+  return mentions.join(' ') + ' '
+}
 
 const PostStatusForm = {
   props: [
-    'replyTo'
+    'replyTo',
+    'repliedUser',
+    'attentions'
   ],
   data () {
+    let statusText = ''
+
+    if (this.replyTo) {
+      const currentUser = this.$store.state.users.currentUser
+      statusText = buildMentionsString({ user: this.repliedUser, attentions: this.attentions }, currentUser)
+    }
+
     return {
-      newStatus: { }
+      newStatus: {
+        status: statusText
+      }
     }
   },
   methods: {
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index ab827325..f3d36c54 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -45,7 +45,7 @@
             <favorite-button :status=status></favorite-button>
           </div>
 
-          <post-status-form v-if="replying" :reply-to="status.id"></post-status-form>
+          <post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user"></post-status-form>
         </div>
       </div>
     </div>
-- 
cgit v1.2.3-70-g09d2


From 572aceb7e7a86c227f2d92c0abf651ba9c3cb4df Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Thu, 3 Nov 2016 17:35:49 +0100
Subject: Hide after posting.

---
 src/components/post_status_form/post_status_form.js | 1 +
 src/components/status/status.vue                    | 4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

(limited to 'src/components/status/status.vue')

diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index 0d4d87f2..2c015154 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -45,6 +45,7 @@ const PostStatusForm = {
         inReplyToStatusId: this.replyTo
       })
       this.newStatus = { }
+      this.$emit('posted')
     }
   }
 }
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index f3d36c54..8361aa52 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -35,7 +35,7 @@
         <div>
           <div class='status-actions'>
             <div>
-              <a href="#" v-on:click.prevent="toggleReplying()">
+              <a href="#" v-on:click.prevent="toggleReplying">
                 <i class='fa icon-reply'></i>
               </a>
             </div>
@@ -45,7 +45,7 @@
             <favorite-button :status=status></favorite-button>
           </div>
 
-          <post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user"></post-status-form>
+          <post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user" v-on:posted="toggleReplying"></post-status-form>
         </div>
       </div>
     </div>
-- 
cgit v1.2.3-70-g09d2

