Merge branch 'develop' of ssh.gitgud.io:lambadalambda/pleroma-fe into develop
This commit is contained in:
commit
590782701d
5 changed files with 84 additions and 1 deletions
|
@ -6,6 +6,24 @@
|
||||||
<span class="glyphicon glyphicon-user"></span>
|
<span class="glyphicon glyphicon-user"></span>
|
||||||
<div class='user-name'>{{user.name}}</div>
|
<div class='user-name'>{{user.name}}</div>
|
||||||
<div class='user-screen-name'>@{{user.screen_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!
|
||||||
|
<button @click="unfollowUser">
|
||||||
|
Unfollow!
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
<span v-if="!user.following" >
|
||||||
|
<button @click="followUser">
|
||||||
|
Follow!
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
@ -37,6 +55,21 @@
|
||||||
color: `#${this.user.profile_link_color}`,
|
color: `#${this.user.profile_link_color}`,
|
||||||
'background-image': `url(${this.user.cover_photo})`
|
'background-image': `url(${this.user.cover_photo})`
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
isOtherUser () {
|
||||||
|
return this.user !== this.$store.state.users.currentUser
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
followUser () {
|
||||||
|
const store = this.$store
|
||||||
|
store.state.api.backendInteractor.followUser(this.user.id)
|
||||||
|
.then((followedUser) => store.commit('addNewUsers', [followedUser]))
|
||||||
|
},
|
||||||
|
unfollowUser () {
|
||||||
|
const store = this.$store
|
||||||
|
store.state.api.backendInteractor.unfollowUser(this.user.id)
|
||||||
|
.then((unfollowedUser) => store.commit('addNewUsers', [unfollowedUser]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,3 +5,20 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./user_profile.js"></script>
|
<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>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import timelineFetcher from '../services/timeline_fetcher/timeline_fetcher.service.js'
|
import timelineFetcher from '../services/timeline_fetcher/timeline_fetcher.service.js'
|
||||||
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
||||||
import { map, each, find, merge } from 'lodash'
|
import { compact, map, each, find, merge } from 'lodash'
|
||||||
|
|
||||||
// TODO: Unify with mergeOrAdd in statuses.js
|
// TODO: Unify with mergeOrAdd in statuses.js
|
||||||
export const mergeOrAdd = (arr, item) => {
|
export const mergeOrAdd = (arr, item) => {
|
||||||
|
@ -44,7 +44,9 @@ const users = {
|
||||||
actions: {
|
actions: {
|
||||||
addNewStatuses (store, { statuses }) {
|
addNewStatuses (store, { statuses }) {
|
||||||
const users = map(statuses, 'user')
|
const users = map(statuses, 'user')
|
||||||
|
const retweetedUsers = compact(map(statuses, 'retweeted_status.user'))
|
||||||
store.commit('addNewUsers', users)
|
store.commit('addNewUsers', users)
|
||||||
|
store.commit('addNewUsers', retweetedUsers)
|
||||||
},
|
},
|
||||||
loginUser (store, userCredentials) {
|
loginUser (store, userCredentials) {
|
||||||
const commit = store.commit
|
const commit = store.commit
|
||||||
|
|
|
@ -13,6 +13,9 @@ const MEDIA_UPLOAD_URL = '/api/statusnet/media/upload'
|
||||||
const CONVERSATION_URL = '/api/statusnet/conversation'
|
const CONVERSATION_URL = '/api/statusnet/conversation'
|
||||||
const MENTIONS_URL = '/api/statuses/mentions.json'
|
const MENTIONS_URL = '/api/statuses/mentions.json'
|
||||||
const FRIENDS_URL = '/api/statuses/friends.json'
|
const FRIENDS_URL = '/api/statuses/friends.json'
|
||||||
|
const FOLLOWING_URL = '/api/friendships/create.json'
|
||||||
|
const UNFOLLOWING_URL = '/api/friendships/destroy.json'
|
||||||
|
// const USER_URL = '/api/users/show.json'
|
||||||
|
|
||||||
const oldfetch = window.fetch
|
const oldfetch = window.fetch
|
||||||
|
|
||||||
|
@ -30,6 +33,22 @@ 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 unfollowUser = ({id, credentials}) => {
|
||||||
|
let url = `${UNFOLLOWING_URL}?user_id=${id}`
|
||||||
|
return fetch(url, {
|
||||||
|
headers: authHeaders(credentials),
|
||||||
|
method: 'POST'
|
||||||
|
}).then((data) => data.json())
|
||||||
|
}
|
||||||
|
|
||||||
const fetchFriends = ({credentials}) => {
|
const fetchFriends = ({credentials}) => {
|
||||||
return fetch(FRIENDS_URL, { headers: authHeaders(credentials) })
|
return fetch(FRIENDS_URL, { headers: authHeaders(credentials) })
|
||||||
.then((data) => data.json())
|
.then((data) => data.json())
|
||||||
|
@ -143,6 +162,8 @@ const apiService = {
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
fetchMentions,
|
fetchMentions,
|
||||||
fetchFriends,
|
fetchFriends,
|
||||||
|
followUser,
|
||||||
|
unfollowUser,
|
||||||
favorite,
|
favorite,
|
||||||
unfavorite,
|
unfavorite,
|
||||||
retweet,
|
retweet,
|
||||||
|
|
|
@ -17,11 +17,21 @@ const backendInteractorService = (credentials) => {
|
||||||
return apiService.fetchFriends({credentials})
|
return apiService.fetchFriends({credentials})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const followUser = (id) => {
|
||||||
|
return apiService.followUser({credentials, id})
|
||||||
|
}
|
||||||
|
|
||||||
|
const unfollowUser = (id) => {
|
||||||
|
return apiService.unfollowUser({credentials, id})
|
||||||
|
}
|
||||||
|
|
||||||
const backendInteractorServiceInstance = {
|
const backendInteractorServiceInstance = {
|
||||||
fetchStatus,
|
fetchStatus,
|
||||||
fetchConversation,
|
fetchConversation,
|
||||||
fetchMentions,
|
fetchMentions,
|
||||||
fetchFriends,
|
fetchFriends,
|
||||||
|
followUser,
|
||||||
|
unfollowUser,
|
||||||
verifyCredentials: apiService.verifyCredentials
|
verifyCredentials: apiService.verifyCredentials
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue