From 66ef9f1328f155d50775d55445522c11cd17fa01 Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Mon, 13 Feb 2017 23:22:32 +0100
Subject: Add users muting.

---
 src/components/user_card_content/user_card_content.vue | 8 ++++++++
 1 file changed, 8 insertions(+)

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

diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue
index 9a21f404..b44dcaa9 100644
--- a/src/components/user_card_content/user_card_content.vue
+++ b/src/components/user_card_content/user_card_content.vue
@@ -3,6 +3,10 @@
     <div class="base00-background panel-heading text-center" v-bind:style="style">
       <div class='user-info'>
         <img :src="user.profile_image_url">
+        <div v-if='user.muted' class='muteinfo'>Muted</div>
+        <div class='muteinfo'>
+          <button @click="toggleMute">Mute/Unmute</button>
+        </div>
         <span class="glyphicon glyphicon-user"></span>
         <div class='user-name'>{{user.name}}</div>
         <div class='user-screen-name'>@{{user.screen_name}}</div>
@@ -70,6 +74,10 @@
         const store = this.$store
         store.state.api.backendInteractor.unfollowUser(this.user.id)
           .then((unfollowedUser) => store.commit('addNewUsers', [unfollowedUser]))
+      },
+      toggleMute () {
+        const store = this.$store
+        store.commit('setMuted', {user: this.user, muted: !this.user.muted})
       }
     }
   }
-- 
cgit v1.2.3-70-g09d2


From 4c12de262ff1ca9cde925195de20158c33f7bad0 Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Tue, 14 Feb 2017 00:01:50 +0100
Subject: Add muting to statuses.

---
 src/components/status/status.js                    |   9 +-
 src/components/status/status.vue                   | 115 +++++++++++----------
 .../user_card_content/user_card_content.vue        |   2 +-
 src/modules/users.js                               |   9 ++
 4 files changed, 80 insertions(+), 55 deletions(-)

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

diff --git a/src/components/status/status.js b/src/components/status/status.js
index 40589ea5..3d1d50fb 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -11,7 +11,8 @@ const Status = {
   ],
   data: () => ({
     replying: false,
-    expanded: false
+    expanded: false,
+    unmuted: false
   }),
   computed: {
     retweet () { return !!this.statusoid.retweeted_status },
@@ -25,7 +26,8 @@ const Status = {
     },
     loggedIn () {
       return !!this.$store.state.users.currentUser
-    }
+    },
+    muted () { return !this.unmuted && this.status.user.muted }
   },
   components: {
     Attachment,
@@ -40,6 +42,9 @@ const Status = {
     },
     toggleExpanded () {
       this.$emit('toggleExpanded')
+    },
+    toggleMute () {
+      this.unmuted = !this.unmuted
     }
   }
 }
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index f113fb7e..95abdd5b 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -1,70 +1,78 @@
 <template>
   <div class="status-el base00-background" v-if="!status.deleted">
-    <div v-if="retweet" class="media container retweet-info">
-      <div class="media-left">
-        <i class='fa icon-retweet retweeted'></i>
+    <template v-if="muted">
+      <div class="media status container muted">
+        <small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
+        <button @click="toggleMute">show</button>
       </div>
-      <div class="media-body">
-        Retweeted by {{retweeter}}
-      </div>
-    </div>
-    <div class="media status container">
-      <div class="media-left">
-        <a :href="status.user.statusnet_profile_url">
-          <img class='avatar' :src="status.user.profile_image_url_original">
-        </a>
+    </template>
+    <template v-if="!muted">
+      <div v-if="retweet" class="media container retweet-info">
+        <div class="media-left">
+          <i class='fa icon-retweet retweeted'></i>
+        </div>
+        <div class="media-body">
+          Retweeted by {{retweeter}}
+        </div>
       </div>
-      <div class="media-body">
-        <div class="user-content">
-          <h4 class="media-heading">
-            {{status.user.name}}
-            <small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
-            <small v-if="status.in_reply_to_screen_name"> &gt;
-              <router-link :to="{ name: 'user-profile', params: { id: status.in_reply_to_user_id } }">
-                {{status.in_reply_to_screen_name}}
-              </router-link>
-            </small>
-            -
-            <small>
-              <router-link :to="{ name: 'conversation', params: { id: status.id } }">
-                <timeago :since="status.created_at" :auto-update="60"></timeago>
-              </router-link>
-            </small>
-            <template v-if="expandable">
+      <div class="media status container">
+        <div class="media-left">
+          <a :href="status.user.statusnet_profile_url">
+            <img class='avatar' :src="status.user.profile_image_url_original">
+          </a>
+        </div>
+        <div class="media-body">
+          <div class="user-content">
+            <h4 class="media-heading">
+              {{status.user.name}}
+              <small><router-link :to="{ name: 'user-profile', params: { id: status.user.id } }">{{status.user.screen_name}}</router-link></small>
+              <small v-if="status.in_reply_to_screen_name"> &gt;
+                <router-link :to="{ name: 'user-profile', params: { id: status.in_reply_to_user_id } }">
+                  {{status.in_reply_to_screen_name}}
+                </router-link>
+              </small>
               -
               <small>
-                <a href="#" @click.prevent="toggleExpanded" >Expand</a>
+                <router-link :to="{ name: 'conversation', params: { id: status.id } }">
+                  <timeago :since="status.created_at" :auto-update="60"></timeago>
+                </router-link>
+              </small>
+              <template v-if="expandable">
+                -
+                <small>
+                  <a href="#" @click.prevent="toggleExpanded" >Expand</a>
+                </small>
+              </template>
+              <small v-if="!status.is_local" class="source_url">
+                <a :href="status.external_url" target="_blank" >Source</a>
               </small>
-            </template>
-            <small v-if="!status.is_local" class="source_url">
-              <a :href="status.external_url" target="_blank" >Source</a>
-            </small>
-          </h4>
+            </h4>
 
-          <div class="status-content" v-html="status.statusnet_html"></div>
+            <div class="status-content" v-html="status.statusnet_html"></div>
 
-          <div v-if='status.attachments' class='attachments'>
-            <attachment :status-id="status.id" :nsfw="status.nsfw" :attachment="attachment" v-for="attachment in status.attachments">
-            </attachment>
+            <div v-if='status.attachments' class='attachments'>
+              <attachment :status-id="status.id" :nsfw="status.nsfw" :attachment="attachment" v-for="attachment in status.attachments">
+              </attachment>
+            </div>
           </div>
-        </div>
 
-        <div v-if="loggedIn">
-          <div class='status-actions'>
-            <div>
-              <a href="#" v-on:click.prevent="toggleReplying">
-                <i class='fa icon-reply'></i>
-              </a>
+          <div v-if="loggedIn">
+            <div class='status-actions'>
+              <div>
+                <a href="#" v-on:click.prevent="toggleReplying">
+                  <i class='fa icon-reply'></i>
+                </a>
+              </div>
+              <retweet-button :status=status></retweet-button>
+              <favorite-button :status=status></favorite-button>
+              <delete-button :status=status></delete-button>
             </div>
-            <retweet-button :status=status></retweet-button>
-            <favorite-button :status=status></favorite-button>
-            <delete-button :status=status></delete-button>
-          </div>
 
-          <post-status-form v-if="replying" :reply-to="status.id" :attentions="status.attentions" :repliedUser="status.user" v-on:posted="toggleReplying"></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>
-    </div>
+    </template>
   </div>
 </template>
 
@@ -128,4 +136,7 @@
      padding-right: 1em;
      border-bottom: 1px solid;
  }
+ .muted button {
+   margin-left: auto;
+ }
 </style>
diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue
index b44dcaa9..2c32406b 100644
--- a/src/components/user_card_content/user_card_content.vue
+++ b/src/components/user_card_content/user_card_content.vue
@@ -4,7 +4,7 @@
       <div class='user-info'>
         <img :src="user.profile_image_url">
         <div v-if='user.muted' class='muteinfo'>Muted</div>
-        <div class='muteinfo'>
+        <div class='muteinfo' v-if='isOtherUser'>
           <button @click="toggleMute">Mute/Unmute</button>
         </div>
         <span class="glyphicon glyphicon-user"></span>
diff --git a/src/modules/users.js b/src/modules/users.js
index 544ca158..546015ba 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -52,6 +52,15 @@ const users = {
       const retweetedUsers = compact(map(statuses, 'retweeted_status.user'))
       store.commit('addNewUsers', users)
       store.commit('addNewUsers', retweetedUsers)
+
+      // Reconnect users to statuses
+      each(statuses, (status) => {
+        status.user = find(store.state.users, status.user)
+      })
+      // Reconnect users to retweets
+      each(compact(map(statuses, 'retweeted_status')), (status) => {
+        status.user = find(store.state.users, status.user)
+      })
     },
     loginUser (store, userCredentials) {
       const commit = store.commit
-- 
cgit v1.2.3-70-g09d2

