From 7516cd859f0c9bc078548f801cbb6a63b72ced97 Mon Sep 17 00:00:00 2001
From: Roger Braun <rbraun@Bobble.local>
Date: Tue, 7 Nov 2017 15:14:37 +0100
Subject: Prepare for i18n.

---
 .../user_card_content/user_card_content.vue        | 28 ++++++++++++----------
 1 file changed, 16 insertions(+), 12 deletions(-)

(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 baa71cd0..4895f36f 100644
--- a/src/components/user_card_content/user_card_content.vue
+++ b/src/components/user_card_content/user_card_content.vue
@@ -19,27 +19,31 @@
         </div>
         <div v-if="isOtherUser" class="user-interactions">
           <div v-if="user.follows_you && loggedIn" class="following base06">
-            Follows you!
+            {{ $t('user_card.follows_you') }}
           </div>
           <div class="follow" v-if="loggedIn">
             <span v-if="user.following">
               <!--Following them!-->
               <button @click="unfollowUser" class="base04 base00-background pressed">
-                Following!
+                {{ $t('user_card.following') }}
               </button>
             </span>
             <span v-if="!user.following">
               <button @click="followUser" class="base05 base02-background">
-                Follow
+                {{ $t('user_card.follow') }}
               </button>
             </span>
           </div>
           <div class='mute' v-if='isOtherUser'>
             <span v-if='user.muted'>
-              <button @click="toggleMute" class="base04 base00-background pressed">Muted</button>
+              <button @click="toggleMute" class="base04 base00-background pressed">
+                {{ $t('user_card.muted') }}
+              </button>
             </span>
             <span v-if='!user.muted'>
-              <button @click="toggleMute" class="base05 base02-background">Mute</button>
+              <button @click="toggleMute" class="base05 base02-background">
+                {{ $t('user_card.mute') }}
+              </button>
             </span>
           </div>
         </div>
@@ -48,18 +52,18 @@
     <div class="panel-body profile-panel-body" :style="bodyStyle">
       <div class="user-counts">
         <div class="user-count">
-          <a href="#" v-on:click.prevent="setProfileView('statuses')" v-if="switcher"><h5 class="base05">Statuses</h5></a>
-          <h5 v-else>Statuses</h5>
-          <span class="base05">{{user.statuses_count}} <br><span class="dailyAvg">{{dailyAvg}} per day</span></span>
+          <a href="#" v-on:click.prevent="setProfileView('statuses')" v-if="switcher"><h5 class="base05">{{ $t('user_card.statuses') }}</h5></a>
+          <h5 v-else>{{ $t('user_card.statuses') }}</h5>
+          <span class="base05">{{user.statuses_count}} <br><span class="dailyAvg">{{dailyAvg}} {{ $t('user_card.per_day') }}</span></span>
         </div>
         <div class="user-count">
-          <a href="#" v-on:click.prevent="setProfileView('friends')" v-if="switcher"><h5 class="base05">Following</h5></a>
-          <h5 v-else>Following</h5>
+          <a href="#" v-on:click.prevent="setProfileView('friends')" v-if="switcher"><h5 class="base05">{{ $t('user_card.followees') }}</h5></a>
+          <h5 v-else>{{ $t('user_card.followees') }}</h5>
           <span class="base05">{{user.friends_count}}</span>
         </div>
         <div class="user-count">
-          <a href="#" v-on:click.prevent="setProfileView('followers')" v-if="switcher"><h5 class="base05">Followers</h5></a>
-          <h5 v-else>Followers</h5>
+          <a href="#" v-on:click.prevent="setProfileView('followers')" v-if="switcher"><h5 class="base05">{{ $t('user_card.followers') }}</h5></a>
+          <h5 v-else>{{ $t('user_card.followers') }}</h5>
           <span class="base05">{{user.followers_count}}</span>
         </div>
       </div>
-- 
cgit v1.2.3-70-g09d2


From 608d1e6776769b933e194f96b4892a888880f60f Mon Sep 17 00:00:00 2001
From: eal <eal@waifu.club>
Date: Tue, 7 Nov 2017 22:38:28 +0200
Subject: Add blocks.

---
 .../user_card_content/user_card_content.vue        | 22 ++++++++++++++++++++++
 src/i18n/messages.js                               |  2 ++
 src/services/api/api.service.js                    | 20 ++++++++++++++++++++
 .../backend_interactor_service.js                  | 10 ++++++++++
 4 files changed, 54 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 4895f36f..8aef7e8a 100644
--- a/src/components/user_card_content/user_card_content.vue
+++ b/src/components/user_card_content/user_card_content.vue
@@ -46,6 +46,18 @@
               </button>
             </span>
           </div>
+          <div class='block' v-if='isOtherUser'>
+            <span v-if='user.statusnet_blocking'>
+              <button @click="unblockUser" class="base04 base00-background pressed">
+                {{ $t('user_card.blocked') }}
+              </button>
+            </span>
+            <span v-if='!user.statusnet_blocking'>
+              <button @click="blockUser" class="base05 base02-background">
+                {{ $t('user_card.block') }}
+              </button>
+            </span>
+          </div>
         </div>
       </div>
     </div>
@@ -113,6 +125,16 @@
         store.state.api.backendInteractor.unfollowUser(this.user.id)
           .then((unfollowedUser) => store.commit('addNewUsers', [unfollowedUser]))
       },
+      blockUser () {
+        const store = this.$store
+        store.state.api.backendInteractor.blockUser(this.user.id)
+          .then((blockedUser) => store.commit('addNewUsers', [blockedUser]))
+      },
+      unblockUser () {
+        const store = this.$store
+        store.state.api.backendInteractor.unblockUser(this.user.id)
+          .then((unblockedUser) => store.commit('addNewUsers', [unblockedUser]))
+      },
       toggleMute () {
         const store = this.$store
         store.commit('setMuted', {user: this.user, muted: !this.user.muted})
diff --git a/src/i18n/messages.js b/src/i18n/messages.js
index 3cbde819..3102d946 100644
--- a/src/i18n/messages.js
+++ b/src/i18n/messages.js
@@ -125,6 +125,8 @@ const en = {
     follows_you: 'Follows you!',
     following: 'Following!',
     follow: 'Follow',
+    blocked: 'Blocked!',
+    block: 'Block',
     statuses: 'Statuses',
     mute: 'Mute',
     muted: 'Muted',
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index a1c6b657..5abaea7e 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -26,6 +26,8 @@ const BANNER_UPDATE_URL = '/api/account/update_profile_banner.json'
 const PROFILE_UPDATE_URL = '/api/account/update_profile.json'
 const EXTERNAL_PROFILE_URL = '/api/externalprofile/show.json'
 const QVITTER_USER_TIMELINE_URL = '/api/qvitter/statuses/user_timeline.json'
+const BLOCKING_URL = '/api/blocks/create.json'
+const UNBLOCKING_URL = '/api/blocks/destroy.json'
 // const USER_URL = '/api/users/show.json'
 
 import { each, map } from 'lodash'
@@ -184,6 +186,22 @@ const unfollowUser = ({id, credentials}) => {
   }).then((data) => data.json())
 }
 
+const blockUser = ({id, credentials}) => {
+  let url = `${BLOCKING_URL}?user_id=${id}`
+  return fetch(url, {
+    headers: authHeaders(credentials),
+    method: 'POST'
+  }).then((data) => data.json())
+}
+
+const unblockUser = ({id, credentials}) => {
+  let url = `${UNBLOCKING_URL}?user_id=${id}`
+  return fetch(url, {
+    headers: authHeaders(credentials),
+    method: 'POST'
+  }).then((data) => data.json())
+}
+
 const fetchFriends = ({id, credentials}) => {
   let url = `${FRIENDS_URL}?user_id=${id}`
   return fetch(url, { headers: authHeaders(credentials) })
@@ -343,6 +361,8 @@ const apiService = {
   fetchFollowers,
   followUser,
   unfollowUser,
+  blockUser,
+  unblockUser,
   favorite,
   unfavorite,
   retweet,
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index a99ea38a..51a46e45 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -30,6 +30,14 @@ const backendInteractorService = (credentials) => {
     return apiService.unfollowUser({credentials, id})
   }
 
+  const blockUser = (id) => {
+    return apiService.blockUser({credentials, id})
+  }
+
+  const unblockUser = (id) => {
+    return apiService.unblockUser({credentials, id})
+  }
+
   const startFetching = ({timeline, store, userId = false}) => {
     return timelineFetcherService.startFetching({timeline, store, credentials, userId})
   }
@@ -55,6 +63,8 @@ const backendInteractorService = (credentials) => {
     fetchFollowers,
     followUser,
     unfollowUser,
+    blockUser,
+    unblockUser,
     fetchAllFollowing,
     verifyCredentials: apiService.verifyCredentials,
     startFetching,
-- 
cgit v1.2.3-70-g09d2

