Browse Source

Update PostComponent

Daniel Supernault 6 years ago
parent
commit
58a9d5af98
1 changed files with 42 additions and 6 deletions
  1. 42 6
      resources/assets/js/components/PostComponent.vue

+ 42 - 6
resources/assets/js/components/PostComponent.vue

@@ -137,6 +137,18 @@
                             <span v-if="reply.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3">{{reply.favourites_count == 1 ? '1 like' : reply.favourites_count + ' likes'}}</span>
                             <span v-if="reply.favourites_count" class="text-muted comment-reaction font-weight-bold mr-3">{{reply.favourites_count == 1 ? '1 like' : reply.favourites_count + ' likes'}}</span>
                             <span class="text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply)">Reply</span>
                             <span class="text-muted comment-reaction font-weight-bold cursor-pointer" v-on:click="replyFocus(reply)">Reply</span>
                           </p>
                           </p>
+                          <div v-if="reply.reply_count > 0" class="cursor-pointer" style="margin-left:30px;" v-on:click="toggleReplies(reply)">
+                             <span class="show-reply-bar"></span>
+                             <span class="comment-reaction font-weight-bold text-muted">{{reply.thread ? 'Hide' : 'View'}} Replies ({{reply.reply_count}})</span>
+                          </div>
+                          <div v-if="reply.thread == true" class="comment-thread">
+                            <p class="d-flex justify-content-between align-items-top read-more pb-3" style="overflow-y: hidden;" v-for="(s, index) in reply.replies">
+                              <span>
+                                <a class="text-dark font-weight-bold mr-1" :href="s.account.url" :title="s.account.username">{{s.account.username}}</a>
+                                <span class="text-break" v-html="s.content"></span>
+                              </span>
+                            </p>
+                          </div>
                         </div>
                         </div>
                       </div>
                       </div>
                     </div>
                     </div>
@@ -331,7 +343,7 @@
   }
   }
   .emoji-reactions .nav-item {
   .emoji-reactions .nav-item {
     font-size: 1.2rem;
     font-size: 1.2rem;
-    padding: 7px;
+    padding: 9px;
     cursor: pointer;
     cursor: pointer;
   }
   }
   .emoji-reactions::-webkit-scrollbar {
   .emoji-reactions::-webkit-scrollbar {
@@ -372,7 +384,9 @@ export default {
             showComments: false,
             showComments: false,
             warning: false,
             warning: false,
             loaded: false,
             loaded: false,
-            loading: null
+            loading: null,
+            replyingToId: this.statusId,
+            emoji: ['๐Ÿ˜€','๐Ÿ˜','๐Ÿ˜‚','๐Ÿคฃ','๐Ÿ˜ƒ','๐Ÿ˜„','๐Ÿ˜…','๐Ÿ˜†','๐Ÿ˜‰','๐Ÿ˜Š','๐Ÿ˜‹','๐Ÿ˜Ž','๐Ÿ˜','๐Ÿ˜˜','๐Ÿ˜—','๐Ÿ˜™','๐Ÿ˜š','โ˜บ๏ธ','๐Ÿ™‚','๐Ÿค—','๐Ÿคฉ','๐Ÿค”','๐Ÿคจ','๐Ÿ˜','๐Ÿ˜‘','๐Ÿ˜ถ','๐Ÿ™„','๐Ÿ˜','๐Ÿ˜ฃ','๐Ÿ˜ฅ','๐Ÿ˜ฎ','๐Ÿค','๐Ÿ˜ฏ','๐Ÿ˜ช','๐Ÿ˜ซ','๐Ÿ˜ด','๐Ÿ˜Œ','๐Ÿ˜›','๐Ÿ˜œ','๐Ÿ˜','๐Ÿคค','๐Ÿ˜’','๐Ÿ˜“','๐Ÿ˜”','๐Ÿ˜•','๐Ÿ™ƒ','๐Ÿค‘','๐Ÿ˜ฒ','โ˜น๏ธ','๐Ÿ™','๐Ÿ˜–','๐Ÿ˜ž','๐Ÿ˜Ÿ','๐Ÿ˜ค','๐Ÿ˜ข','๐Ÿ˜ญ','๐Ÿ˜ฆ','๐Ÿ˜ง','๐Ÿ˜จ','๐Ÿ˜ฉ','๐Ÿคฏ','๐Ÿ˜ฌ','๐Ÿ˜ฐ','๐Ÿ˜ฑ','๐Ÿ˜ณ','๐Ÿคช','๐Ÿ˜ต','๐Ÿ˜ก','๐Ÿ˜ ','๐Ÿคฌ','๐Ÿ˜ท','๐Ÿค’','๐Ÿค•','๐Ÿคข','๐Ÿคฎ','๐Ÿคง','๐Ÿ˜‡','๐Ÿค ','๐Ÿคก','๐Ÿคฅ','๐Ÿคซ','๐Ÿคญ','๐Ÿง','๐Ÿค“','๐Ÿ˜ˆ','๐Ÿ‘ฟ','๐Ÿ‘น','๐Ÿ‘บ','๐Ÿ’€','๐Ÿ‘ป','๐Ÿ‘ฝ','๐Ÿค–','๐Ÿ’ฉ','๐Ÿ˜บ','๐Ÿ˜ธ','๐Ÿ˜น','๐Ÿ˜ป','๐Ÿ˜ผ','๐Ÿ˜ฝ','๐Ÿ™€','๐Ÿ˜ฟ','๐Ÿ˜พ','๐Ÿคฒ','๐Ÿ‘','๐Ÿ™Œ','๐Ÿ‘','๐Ÿค','๐Ÿ‘','๐Ÿ‘Ž','๐Ÿ‘Š','โœŠ','๐Ÿค›','๐Ÿคœ','๐Ÿคž','โœŒ๏ธ','๐ŸคŸ','๐Ÿค˜','๐Ÿ‘Œ','๐Ÿ‘ˆ','๐Ÿ‘‰','๐Ÿ‘†','๐Ÿ‘‡','โ˜๏ธ','โœ‹','๐Ÿคš','๐Ÿ–','๐Ÿ––','๐Ÿ‘‹','๐Ÿค™','๐Ÿ’ช','๐Ÿ–•','โœ๏ธ','๐Ÿ™','๐Ÿ’','๐Ÿ’„','๐Ÿ’‹','๐Ÿ‘„','๐Ÿ‘…','๐Ÿ‘‚','๐Ÿ‘ƒ','๐Ÿ‘ฃ','๐Ÿ‘','๐Ÿ‘€','๐Ÿง ','๐Ÿ—ฃ','๐Ÿ‘ค','๐Ÿ‘ฅ'],
           }
           }
     },
     },
 
 
@@ -668,16 +682,20 @@ export default {
           return;
           return;
         }
         }
         let data = {
         let data = {
-          item: this.statusId,
+          item: this.replyingToId,
           comment: this.replyText
           comment: this.replyText
         }
         }
         axios.post('/i/comment', data)
         axios.post('/i/comment', data)
         .then(function(res) {
         .then(function(res) {
           let entity = res.data.entity;
           let entity = res.data.entity;
-          self.results.push(entity);
+          if(entity.in_reply_to_id == self.status.id) {
+            self.results.push(entity);
+            let elem = $('.status-comments')[0];
+            elem.scrollTop = elem.clientHeight;
+          } else {
+
+          }
           self.replyText = '';
           self.replyText = '';
-          let elem = $('.status-comments')[0];
-          elem.scrollTop = elem.clientHeight;
         });
         });
       },
       },
 
 
@@ -699,6 +717,7 @@ export default {
       },
       },
 
 
       replyFocus(e) {
       replyFocus(e) {
+          this.replyingToId = e.id;
           this.reply_to_profile_id = e.account.id;
           this.reply_to_profile_id = e.account.id;
           this.replyText = '@' + e.account.username + ' ';
           this.replyText = '@' + e.account.username + ' ';
           $('textarea[name="comment"]').focus();
           $('textarea[name="comment"]').focus();
@@ -910,6 +929,23 @@ export default {
             swal('Private Post', 'This post is only visible to followers.', 'info');
             swal('Private Post', 'This post is only visible to followers.', 'info');
           break;
           break;
         }
         }
+      },
+
+      toggleReplies(reply) {
+        if(reply.thread) {
+          reply.thread = false;
+        } else {
+          if(reply.replies.length > 0) {
+            reply.thread = true;
+            return;
+          }
+          let url = '/api/v2/comments/'+reply.account.username+'/status/'+reply.id;
+          axios.get(url)
+            .then(response => {
+                reply.replies = _.reverse(response.data.data);
+                reply.thread = true;
+            });
+        }
       }
       }
 
 
     },
     },