aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/components/user_card_content/user_card_content.vue24
-rw-r--r--src/components/user_profile/user_profile.vue17
-rw-r--r--src/services/api/api.service.js12
-rw-r--r--src/services/backend_interactor_service/backend_interactor_service.js5
4 files changed, 58 insertions, 0 deletions
diff --git a/src/components/user_card_content/user_card_content.vue b/src/components/user_card_content/user_card_content.vue
index 7ad86e63..484597ab 100644
--- a/src/components/user_card_content/user_card_content.vue
+++ b/src/components/user_card_content/user_card_content.vue
@@ -6,6 +6,21 @@
<span class="glyphicon glyphicon-user"></span>
<div class='user-name'>{{user.name}}</div>
<div class='user-screen-name'>@{{user.screen_name}}</div>
+ <div v-if="isOtherUser" class="following-info">
+ <div v-if="user.follows_you" class="following">
+ Follows you!
+ </div>
+ <div class="followed">
+ <span v-if="user.following">
+ Following them!
+ </span>
+ <span v-if="!user.following" >
+ <button @click="followUser">
+ Follow!
+ </button>
+ </span>
+ </div>
+ </div>
</div>
</div>
<div class="panel-body">
@@ -37,6 +52,15 @@
color: `#${this.user.profile_link_color}`,
'background-image': `url(${this.user.cover_photo})`
}
+ },
+ isOtherUser () {
+ return this.user !== this.$store.state.users.currentUser
+ }
+ },
+ methods: {
+ followUser () {
+ this.$store.state.api.backendInteractor.followUser(this.user.id)
+ .then((x) => console.log)
}
}
}
diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue
index eaa5396d..2ceb13ec 100644
--- a/src/components/user_profile/user_profile.vue
+++ b/src/components/user_profile/user_profile.vue
@@ -5,3 +5,20 @@
</template>
<script src="./user_profile.js"></script>
+
+<style lang="scss">
+ .user-profile {
+ flex: 2;
+ flex-basis: 500px;
+ }
+
+ .user-info {
+ .following-info {
+ display: flex;
+
+ div {
+ flex: 1;
+ }
+ }
+ }
+</style>
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index a78ab5c9..106432e7 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -13,6 +13,9 @@ const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload'
const CONVERSATION_URL = '/api/statusnet/conversation'
const MENTIONS_URL = '/api/statuses/mentions.json'
const FRIENDS_URL = '/api/statuses/friends.json'
+const FOLLOWING_URL = '/api/friendships/create.json'
+// const UNFOLLOWING_URL = '/api/friendships/create.json'
+// const USER_URL = '/api/users/show.json'
const oldfetch = window.fetch
@@ -30,6 +33,14 @@ const authHeaders = (user) => {
}
}
+const followUser = ({id, credentials}) => {
+ let url = `${FOLLOWING_URL}?user_id=${id}`
+ return fetch(url, {
+ headers: authHeaders(credentials),
+ method: 'POST'
+ }).then((data) => data.json())
+}
+
const fetchFriends = ({credentials}) => {
return fetch(FRIENDS_URL, { headers: authHeaders(credentials) })
.then((data) => data.json())
@@ -143,6 +154,7 @@ const apiService = {
fetchStatus,
fetchMentions,
fetchFriends,
+ followUser,
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 36a1ff3b..c7cf0f88 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -17,11 +17,16 @@ const backendInteractorService = (credentials) => {
return apiService.fetchFriends({credentials})
}
+ const followUser = (id) => {
+ return apiService.followUser({credentials, id})
+ }
+
const backendInteractorServiceInstance = {
fetchStatus,
fetchConversation,
fetchMentions,
fetchFriends,
+ followUser,
verifyCredentials: apiService.verifyCredentials
}