From 39a6867557e1af5dfa4047dc3e19f80069b744a4 Mon Sep 17 00:00:00 2001
From: Shpuld Shpuldson <shpuld@gmail.com>
Date: Thu, 30 Mar 2017 15:11:32 +0300
Subject: Make muted notifications take much less space (handy for bot spam).

---
 src/components/status/status.vue | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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

diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index 62a55505..993ce796 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -162,8 +162,11 @@
      border-left: 4px rgba(255, 48, 16, 0.65);
      border-left-style: inherit;
  }
- .muted button {
-   margin-left: auto;
+ .muted {
+   padding: 0.1em 0.7em 0.1em 0.8em;
+   button {
+     margin-left: auto;
+   }
  }
 
  a.unmute {
-- 
cgit v1.2.3-70-g09d2


From a53555254a711654399836e0f5f052d629bf4380 Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Sun, 9 Apr 2017 15:53:23 +0200
Subject: Add word-based muting to settings / statuses.

---
 src/components/settings/settings.js  |  6 +++++-
 src/components/settings/settings.vue | 11 ++++++++++-
 src/components/status/status.js      | 14 +++++++++++++-
 src/components/status/status.vue     |  7 ++++++-
 src/main.js                          |  1 +
 src/modules/config.js                |  3 ++-
 6 files changed, 37 insertions(+), 5 deletions(-)

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

diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js
index 3d373283..7aa4bbc4 100644
--- a/src/components/settings/settings.js
+++ b/src/components/settings/settings.js
@@ -5,7 +5,8 @@ const settings = {
     return {
       hideAttachmentsLocal: this.$store.state.config.hideAttachments,
       hideAttachmentsInConvLocal: this.$store.state.config.hideAttachmentsInConv,
-      hideNsfwLocal: this.$store.state.config.hideNsfw
+      hideNsfwLocal: this.$store.state.config.hideNsfw,
+      muteWordsString: this.$store.state.config.muteWords.join('\n')
     }
   },
   components: {
@@ -20,6 +21,9 @@ const settings = {
     },
     hideNsfwLocal (value) {
       this.$store.dispatch('setOption', { name: 'hideNsfw', value })
+    },
+    muteWordsString (value) {
+      this.$store.dispatch('setOption', { name: 'muteWords', value: value.split('\n') })
     }
   }
 }
diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue
index 478d761a..33d46e7e 100644
--- a/src/components/settings/settings.vue
+++ b/src/components/settings/settings.vue
@@ -8,6 +8,11 @@
         <h2>Theme</h2>
         <style-switcher></style-switcher>
       </div>
+      <div class="setting-item">
+        <h2>Filtering</h2>
+        <p>All notices containing these words will be muted, one per line</p>
+        <textarea id="muteWords" v-model="muteWordsString"></textarea>
+      </div>
       <div class="setting-item">
         <h2>Attachments</h2>
         <ul class="setting-list">
@@ -32,9 +37,13 @@
 <script src="./settings.js">
 </script>
 
-<style>
+<style lang="scss">
  .setting-item {
    margin: 1em 1em 1.4em;
+   textarea {
+     width: 100%;
+     height: 100px;
+   }
  }
  .setting-list {
    list-style-type: none;
diff --git a/src/components/status/status.js b/src/components/status/status.js
index 87fff879..bb026fe1 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -4,6 +4,7 @@ import RetweetButton from '../retweet_button/retweet_button.vue'
 import DeleteButton from '../delete_button/delete_button.vue'
 import PostStatusForm from '../post_status_form/post_status_form.vue'
 import UserCardContent from '../user_card_content/user_card_content.vue'
+import { filter } from 'lodash'
 
 const Status = {
   props: [
@@ -19,6 +20,9 @@ const Status = {
     userExpanded: false
   }),
   computed: {
+    muteWords () {
+      return this.$store.state.config.muteWords
+    },
     hideAttachments () {
       return (this.$store.state.config.hideAttachments && !this.inConversation) ||
         (this.$store.state.config.hideAttachmentsInConv && this.inConversation)
@@ -35,7 +39,15 @@ const Status = {
     loggedIn () {
       return !!this.$store.state.users.currentUser
     },
-    muted () { return !this.unmuted && this.status.user.muted },
+    muteWordHits () {
+      const statusText = this.status.text.toLowerCase()
+      const hits = filter(this.muteWords, (muteWord) => {
+        return statusText.includes(muteWord.toLowerCase())
+      })
+
+      return hits
+    },
+    muted () { return !this.unmuted && (this.status.user.muted || this.muteWordHits.length > 0) },
     isReply () { return !!this.status.in_reply_to_status_id },
     borderColor () {
       return {
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index 993ce796..642f1143 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -3,6 +3,7 @@
     <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>
+        <small class="muteWords">{{muteWordHits.join(', ')}}</small>
         <a href="#" class="unmute" @click.prevent="toggleMute"><i class="icon-eye-off"></i></a>
       </div>
     </template>
@@ -52,7 +53,7 @@
                 <small>
                   <a href="#" @click.prevent="toggleExpanded" ><i class="icon-plus-squared"></i></a>
                 </small>
-                <small v-if="status.user.muted">
+                <small v-if="unmuted">
                   <a href="#" @click.prevent="toggleMute" ><i class="icon-eye-off"></i></a>
                 </small>
               </template>
@@ -167,6 +168,10 @@
    button {
      margin-left: auto;
    }
+
+   .muteWords {
+     margin-left: 10px;
+   }
  }
 
  a.unmute {
diff --git a/src/main.js b/src/main.js
index ab0fd6c0..969ca8dc 100644
--- a/src/main.js
+++ b/src/main.js
@@ -33,6 +33,7 @@ const persistedStateOptions = {
     'config.hideAttachments',
     'config.hideAttachmentsInConv',
     'config.hideNsfw',
+    'config.muteWords',
     'statuses.notifications',
     'users.users'
   ]
diff --git a/src/modules/config.js b/src/modules/config.js
index 05b4ab3b..f59dc6f0 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -6,7 +6,8 @@ const defaultState = {
   colors: {},
   hideAttachments: false,
   hideAttachmentsInConv: false,
-  hideNsfw: true
+  hideNsfw: true,
+  muteWords: []
 }
 
 const config = {
-- 
cgit v1.2.3-70-g09d2


From 1ea19dcf1d7548496b4078aee90cb3e4bbad7755 Mon Sep 17 00:00:00 2001
From: Roger Braun <roger@rogerbraun.net>
Date: Sun, 9 Apr 2017 16:39:19 +0200
Subject: Take unmuting out of expandable condition.

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

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

diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index 642f1143..b471888a 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -53,10 +53,10 @@
                 <small>
                   <a href="#" @click.prevent="toggleExpanded" ><i class="icon-plus-squared"></i></a>
                 </small>
-                <small v-if="unmuted">
-                  <a href="#" @click.prevent="toggleMute" ><i class="icon-eye-off"></i></a>
-                </small>
               </template>
+              <small v-if="unmuted">
+                <a href="#" @click.prevent="toggleMute" ><i class="icon-eye-off"></i></a>
+              </small>
               <small v-if="!status.is_local" class="source_url">
                 <a :href="status.external_url" target="_blank" ><i class="icon-binoculars"></i></a>
               </small>
-- 
cgit v1.2.3-70-g09d2

