forked from AkkomaGang/akkoma-fe
Merge branch 'feat/relationship-refactor' into 'develop'
Refactor: make relationships separate from users Closes #819 See merge request pleroma/pleroma-fe!1091
This commit is contained in:
commit
47c56ffa1c
24 changed files with 124 additions and 113 deletions
|
@ -307,6 +307,9 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
|||
getNodeInfo({ store })
|
||||
])
|
||||
|
||||
// Start fetching things that don't need to block the UI
|
||||
store.dispatch('fetchMutes')
|
||||
|
||||
const router = new VueRouter({
|
||||
mode: 'history',
|
||||
routes: routes(store),
|
||||
|
|
|
@ -3,7 +3,7 @@ import Popover from '../popover/popover.vue'
|
|||
|
||||
const AccountActions = {
|
||||
props: [
|
||||
'user'
|
||||
'user', 'relationship'
|
||||
],
|
||||
data () {
|
||||
return { }
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
class="account-tools-popover"
|
||||
>
|
||||
<div class="dropdown-menu">
|
||||
<template v-if="user.following">
|
||||
<template v-if="relationship.following">
|
||||
<button
|
||||
v-if="user.showing_reblogs"
|
||||
v-if="relationship.showing_reblogs"
|
||||
class="btn btn-default dropdown-item"
|
||||
@click="hideRepeats"
|
||||
>
|
||||
{{ $t('user_card.hide_repeats') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!user.showing_reblogs"
|
||||
v-if="!relationship.showing_reblogs"
|
||||
class="btn btn-default dropdown-item"
|
||||
@click="showRepeats"
|
||||
>
|
||||
|
@ -30,7 +30,7 @@
|
|||
/>
|
||||
</template>
|
||||
<button
|
||||
v-if="user.statusnet_blocking"
|
||||
v-if="relationship.blocking"
|
||||
class="btn btn-default btn-block dropdown-item"
|
||||
@click="unblockUser"
|
||||
>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
class="basic-user-card-expanded-content"
|
||||
>
|
||||
<UserCard
|
||||
:user="user"
|
||||
:user-id="user.id"
|
||||
:rounded="true"
|
||||
:bordered="true"
|
||||
/>
|
||||
|
|
|
@ -11,8 +11,11 @@ const BlockCard = {
|
|||
user () {
|
||||
return this.$store.getters.findUser(this.userId)
|
||||
},
|
||||
relationship () {
|
||||
return this.$store.getters.relationship(this.userId)
|
||||
},
|
||||
blocked () {
|
||||
return this.user.statusnet_blocking
|
||||
return this.relationship.blocking
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate'
|
||||
export default {
|
||||
props: ['user', 'labelFollowing', 'buttonClass'],
|
||||
props: ['relationship', 'labelFollowing', 'buttonClass'],
|
||||
data () {
|
||||
return {
|
||||
inProgress: false
|
||||
|
@ -8,12 +8,12 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
isPressed () {
|
||||
return this.inProgress || this.user.following
|
||||
return this.inProgress || this.relationship.following
|
||||
},
|
||||
title () {
|
||||
if (this.inProgress || this.user.following) {
|
||||
if (this.inProgress || this.relationship.following) {
|
||||
return this.$t('user_card.follow_unfollow')
|
||||
} else if (this.user.requested) {
|
||||
} else if (this.relationship.requested) {
|
||||
return this.$t('user_card.follow_again')
|
||||
} else {
|
||||
return this.$t('user_card.follow')
|
||||
|
@ -22,9 +22,9 @@ export default {
|
|||
label () {
|
||||
if (this.inProgress) {
|
||||
return this.$t('user_card.follow_progress')
|
||||
} else if (this.user.following) {
|
||||
} else if (this.relationship.following) {
|
||||
return this.labelFollowing || this.$t('user_card.following')
|
||||
} else if (this.user.requested) {
|
||||
} else if (this.relationship.requested) {
|
||||
return this.$t('user_card.follow_sent')
|
||||
} else {
|
||||
return this.$t('user_card.follow')
|
||||
|
@ -33,20 +33,20 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
onClick () {
|
||||
this.user.following ? this.unfollow() : this.follow()
|
||||
this.relationship.following ? this.unfollow() : this.follow()
|
||||
},
|
||||
follow () {
|
||||
this.inProgress = true
|
||||
requestFollow(this.user, this.$store).then(() => {
|
||||
requestFollow(this.relationship.id, this.$store).then(() => {
|
||||
this.inProgress = false
|
||||
})
|
||||
},
|
||||
unfollow () {
|
||||
const store = this.$store
|
||||
this.inProgress = true
|
||||
requestUnfollow(this.user, store).then(() => {
|
||||
requestUnfollow(this.relationship.id, store).then(() => {
|
||||
this.inProgress = false
|
||||
store.commit('removeStatus', { timeline: 'friends', userId: this.user.id })
|
||||
store.commit('removeStatus', { timeline: 'friends', userId: this.relationship.id })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ const FollowCard = {
|
|||
},
|
||||
loggedIn () {
|
||||
return this.$store.state.users.currentUser
|
||||
},
|
||||
relationship () {
|
||||
return this.$store.getters.relationship(this.user.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
<basic-user-card :user="user">
|
||||
<div class="follow-card-content-container">
|
||||
<span
|
||||
v-if="!noFollowsYou && user.follows_you"
|
||||
v-if="!noFollowsYou && relationship.followed_by"
|
||||
class="faint"
|
||||
>
|
||||
{{ isMe ? $t('user_card.its_you') : $t('user_card.follows_you') }}
|
||||
</span>
|
||||
<template v-if="!loggedIn">
|
||||
<div
|
||||
v-if="!user.following"
|
||||
v-if="!relationship.following"
|
||||
class="follow-card-follow-button"
|
||||
>
|
||||
<RemoteFollow :user="user" />
|
||||
|
@ -17,9 +17,9 @@
|
|||
</template>
|
||||
<template v-else>
|
||||
<FollowButton
|
||||
:user="user"
|
||||
class="follow-card-follow-button"
|
||||
:relationship="relationship"
|
||||
:label-following="$t('user_card.follow_unfollow')"
|
||||
class="follow-card-follow-button"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
|
|
@ -11,8 +11,11 @@ const MuteCard = {
|
|||
user () {
|
||||
return this.$store.getters.findUser(this.userId)
|
||||
},
|
||||
relationship () {
|
||||
return this.$store.getters.relationship(this.userId)
|
||||
},
|
||||
muted () {
|
||||
return this.user.muted
|
||||
return this.relationship.muting
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
@ -21,13 +24,13 @@ const MuteCard = {
|
|||
methods: {
|
||||
unmuteUser () {
|
||||
this.progress = true
|
||||
this.$store.dispatch('unmuteUser', this.user.id).then(() => {
|
||||
this.$store.dispatch('unmuteUser', this.userId).then(() => {
|
||||
this.progress = false
|
||||
})
|
||||
},
|
||||
muteUser () {
|
||||
this.progress = true
|
||||
this.$store.dispatch('muteUser', this.user.id).then(() => {
|
||||
this.$store.dispatch('muteUser', this.userId).then(() => {
|
||||
this.progress = false
|
||||
})
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ const Notification = {
|
|||
return this.generateUserProfileLink(this.targetUser)
|
||||
},
|
||||
needMute () {
|
||||
return this.user.muted
|
||||
return this.$store.getters.relationship(this.user.id).muting
|
||||
},
|
||||
isStatusNotification () {
|
||||
return isStatusNotification(this.notification.type)
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<div class="notification-right">
|
||||
<UserCard
|
||||
v-if="userExpanded"
|
||||
:user="getUser(notification)"
|
||||
:user-id="getUser(notification).id"
|
||||
:rounded="true"
|
||||
:bordered="true"
|
||||
/>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
>
|
||||
<UserCard
|
||||
v-if="currentUser"
|
||||
:user="currentUser"
|
||||
:user-id="currentUser.id"
|
||||
:hide-bio="true"
|
||||
/>
|
||||
<div
|
||||
|
|
|
@ -101,7 +101,13 @@ const Status = {
|
|||
|
||||
return hits
|
||||
},
|
||||
muted () { return !this.unmuted && ((!(this.inProfile && this.status.user.id === this.profileUserId) && this.status.user.muted) || (!this.inConversation && this.status.thread_muted) || this.muteWordHits.length > 0) },
|
||||
muted () {
|
||||
const relationship = this.$store.getters.relationship(this.status.user.id)
|
||||
return !this.unmuted && (
|
||||
(!(this.inProfile && this.status.user.id === this.profileUserId) && relationship.muting) ||
|
||||
(!this.inConversation && this.status.thread_muted) ||
|
||||
this.muteWordHits.length > 0)
|
||||
},
|
||||
hideFilteredStatuses () {
|
||||
return this.mergedConfig.hideFilteredStatuses
|
||||
},
|
||||
|
@ -147,8 +153,11 @@ const Status = {
|
|||
if (this.status.user.id === this.status.attentions[i].id) {
|
||||
continue
|
||||
}
|
||||
const taggedUser = this.$store.getters.findUser(this.status.attentions[i].id)
|
||||
if (checkFollowing && taggedUser && taggedUser.following) {
|
||||
// There's zero guarantee of this working. If we happen to have that user and their
|
||||
// relationship in store then it will work, but there's kinda little chance of having
|
||||
// them for people you're not following.
|
||||
const relationship = this.$store.state.users.relationships[this.status.attentions[i].id]
|
||||
if (checkFollowing && relationship && relationship.following) {
|
||||
return false
|
||||
}
|
||||
if (this.status.attentions[i].id === this.currentUser.id) {
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
<div class="status-body">
|
||||
<UserCard
|
||||
v-if="userExpanded"
|
||||
:user="status.user"
|
||||
:user-id="status.user.id"
|
||||
:rounded="true"
|
||||
:bordered="true"
|
||||
class="status-usercard"
|
||||
|
|
|
@ -9,7 +9,7 @@ import { mapGetters } from 'vuex'
|
|||
|
||||
export default {
|
||||
props: [
|
||||
'user', 'switcher', 'selected', 'hideBio', 'rounded', 'bordered', 'allowZoomingAvatar'
|
||||
'userId', 'switcher', 'selected', 'hideBio', 'rounded', 'bordered', 'allowZoomingAvatar'
|
||||
],
|
||||
data () {
|
||||
return {
|
||||
|
@ -21,6 +21,12 @@ export default {
|
|||
this.$store.dispatch('fetchUserRelationship', this.user.id)
|
||||
},
|
||||
computed: {
|
||||
user () {
|
||||
return this.$store.getters.findUser(this.userId)
|
||||
},
|
||||
relationship () {
|
||||
return this.$store.getters.relationship(this.userId)
|
||||
},
|
||||
classes () {
|
||||
return [{
|
||||
'user-card-rounded-t': this.rounded === 'top', // set border-top-left-radius and border-top-right-radius
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
<AccountActions
|
||||
v-if="isOtherUser && loggedIn"
|
||||
:user="user"
|
||||
:relationship="relationship"
|
||||
/>
|
||||
</div>
|
||||
<div class="bottom-line">
|
||||
|
@ -92,7 +93,7 @@
|
|||
</div>
|
||||
<div class="user-meta">
|
||||
<div
|
||||
v-if="user.follows_you && loggedIn && isOtherUser"
|
||||
v-if="relationship.followed_by && loggedIn && isOtherUser"
|
||||
class="following"
|
||||
>
|
||||
{{ $t('user_card.follows_you') }}
|
||||
|
@ -139,10 +140,10 @@
|
|||
class="user-interactions"
|
||||
>
|
||||
<div class="btn-group">
|
||||
<FollowButton :user="user" />
|
||||
<template v-if="user.following">
|
||||
<FollowButton :relationship="relationship" />
|
||||
<template v-if="relationship.following">
|
||||
<ProgressButton
|
||||
v-if="!user.subscribed"
|
||||
v-if="!relationship.subscribing"
|
||||
class="btn btn-default"
|
||||
:click="subscribeUser"
|
||||
:title="$t('user_card.subscribe')"
|
||||
|
@ -161,7 +162,7 @@
|
|||
</div>
|
||||
<div>
|
||||
<button
|
||||
v-if="user.muted"
|
||||
v-if="relationship.muting"
|
||||
class="btn btn-default btn-block toggled"
|
||||
@click="unmuteUser"
|
||||
>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
class="panel panel-default signed-in"
|
||||
>
|
||||
<UserCard
|
||||
:user="user"
|
||||
:user-id="user.id"
|
||||
:hide-bio="true"
|
||||
rounded="top"
|
||||
/>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
class="user-profile panel panel-default"
|
||||
>
|
||||
<UserCard
|
||||
:user="user"
|
||||
:user-id="userId"
|
||||
:switcher="true"
|
||||
:selected="timeline.viewing"
|
||||
:allow-zooming-avatar="true"
|
||||
|
|
|
@ -351,14 +351,14 @@ const UserSettings = {
|
|||
},
|
||||
filterUnblockedUsers (userIds) {
|
||||
return reject(userIds, (userId) => {
|
||||
const user = this.$store.getters.findUser(userId)
|
||||
return !user || user.statusnet_blocking || user.id === this.$store.state.users.currentUser.id
|
||||
const relationship = this.$store.getters.relationship(this.userId)
|
||||
return relationship.blocking || userId === this.$store.state.users.currentUser.id
|
||||
})
|
||||
},
|
||||
filterUnMutedUsers (userIds) {
|
||||
return reject(userIds, (userId) => {
|
||||
const user = this.$store.getters.findUser(userId)
|
||||
return !user || user.muted || user.id === this.$store.state.users.currentUser.id
|
||||
const relationship = this.$store.getters.relationship(this.userId)
|
||||
return relationship.muting || userId === this.$store.state.users.currentUser.id
|
||||
})
|
||||
},
|
||||
queryUserIds (query) {
|
||||
|
|
|
@ -48,6 +48,11 @@ const unblockUser = (store, id) => {
|
|||
}
|
||||
|
||||
const muteUser = (store, id) => {
|
||||
const predictedRelationship = store.state.relationships[id] || { id }
|
||||
predictedRelationship.muting = true
|
||||
store.commit('updateUserRelationship', [predictedRelationship])
|
||||
store.commit('addMuteId', id)
|
||||
|
||||
return store.rootState.api.backendInteractor.muteUser({ id })
|
||||
.then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
|
@ -56,6 +61,10 @@ const muteUser = (store, id) => {
|
|||
}
|
||||
|
||||
const unmuteUser = (store, id) => {
|
||||
const predictedRelationship = store.state.relationships[id] || { id }
|
||||
predictedRelationship.muting = false
|
||||
store.commit('updateUserRelationship', [predictedRelationship])
|
||||
|
||||
return store.rootState.api.backendInteractor.unmuteUser({ id })
|
||||
.then((relationship) => store.commit('updateUserRelationship', [relationship]))
|
||||
}
|
||||
|
@ -83,10 +92,6 @@ const unmuteDomain = (store, domain) => {
|
|||
}
|
||||
|
||||
export const mutations = {
|
||||
setMuted (state, { user: { id }, muted }) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'muted', muted)
|
||||
},
|
||||
tagUser (state, { user: { id }, tag }) {
|
||||
const user = state.usersObject[id]
|
||||
const tags = user.tags || []
|
||||
|
@ -146,26 +151,18 @@ export const mutations = {
|
|||
}
|
||||
},
|
||||
addNewUsers (state, users) {
|
||||
each(users, (user) => mergeOrAdd(state.users, state.usersObject, user))
|
||||
each(users, (user) => {
|
||||
if (user.relationship) {
|
||||
set(state.relationships, user.relationship.id, user.relationship)
|
||||
}
|
||||
mergeOrAdd(state.users, state.usersObject, user)
|
||||
})
|
||||
},
|
||||
updateUserRelationship (state, relationships) {
|
||||
relationships.forEach((relationship) => {
|
||||
const user = state.usersObject[relationship.id]
|
||||
if (user) {
|
||||
user.follows_you = relationship.followed_by
|
||||
user.following = relationship.following
|
||||
user.muted = relationship.muting
|
||||
user.statusnet_blocking = relationship.blocking
|
||||
user.subscribed = relationship.subscribing
|
||||
user.showing_reblogs = relationship.showing_reblogs
|
||||
}
|
||||
set(state.relationships, relationship.id, relationship)
|
||||
})
|
||||
},
|
||||
updateBlocks (state, blockedUsers) {
|
||||
// Reset statusnet_blocking of all fetched users
|
||||
each(state.users, (user) => { user.statusnet_blocking = false })
|
||||
each(blockedUsers, (user) => mergeOrAdd(state.users, state.usersObject, user))
|
||||
},
|
||||
saveBlockIds (state, blockIds) {
|
||||
state.currentUser.blockIds = blockIds
|
||||
},
|
||||
|
@ -174,11 +171,6 @@ export const mutations = {
|
|||
state.currentUser.blockIds.push(blockId)
|
||||
}
|
||||
},
|
||||
updateMutes (state, mutedUsers) {
|
||||
// Reset muted of all fetched users
|
||||
each(state.users, (user) => { user.muted = false })
|
||||
each(mutedUsers, (user) => mergeOrAdd(state.users, state.usersObject, user))
|
||||
},
|
||||
saveMuteIds (state, muteIds) {
|
||||
state.currentUser.muteIds = muteIds
|
||||
},
|
||||
|
@ -244,6 +236,10 @@ export const getters = {
|
|||
return state.usersObject[query.toLowerCase()]
|
||||
}
|
||||
return result
|
||||
},
|
||||
relationship: state => id => {
|
||||
const rel = id && state.relationships[id]
|
||||
return rel || { id, loading: true }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,7 +250,8 @@ export const defaultState = {
|
|||
users: [],
|
||||
usersObject: {},
|
||||
signUpPending: false,
|
||||
signUpErrors: []
|
||||
signUpErrors: [],
|
||||
relationships: {}
|
||||
}
|
||||
|
||||
const users = {
|
||||
|
@ -279,7 +276,7 @@ const users = {
|
|||
return store.rootState.api.backendInteractor.fetchBlocks()
|
||||
.then((blocks) => {
|
||||
store.commit('saveBlockIds', map(blocks, 'id'))
|
||||
store.commit('updateBlocks', blocks)
|
||||
store.commit('addNewUsers', blocks)
|
||||
return blocks
|
||||
})
|
||||
},
|
||||
|
@ -298,8 +295,8 @@ const users = {
|
|||
fetchMutes (store) {
|
||||
return store.rootState.api.backendInteractor.fetchMutes()
|
||||
.then((mutes) => {
|
||||
store.commit('updateMutes', mutes)
|
||||
store.commit('saveMuteIds', map(mutes, 'id'))
|
||||
store.commit('addNewUsers', mutes)
|
||||
return mutes
|
||||
})
|
||||
},
|
||||
|
@ -416,7 +413,7 @@ const users = {
|
|||
},
|
||||
addNewNotifications (store, { notifications }) {
|
||||
const users = map(notifications, 'from_profile')
|
||||
const targetUsers = map(notifications, 'target')
|
||||
const targetUsers = map(notifications, 'target').filter(_ => _)
|
||||
const notificationIds = notifications.map(_ => _.id)
|
||||
store.commit('addNewUsers', users)
|
||||
store.commit('addNewUsers', targetUsers)
|
||||
|
|
|
@ -75,13 +75,7 @@ export const parseUser = (data) => {
|
|||
output.token = data.pleroma.chat_token
|
||||
|
||||
if (relationship) {
|
||||
output.follows_you = relationship.followed_by
|
||||
output.requested = relationship.requested
|
||||
output.following = relationship.following
|
||||
output.statusnet_blocking = relationship.blocking
|
||||
output.muted = relationship.muting
|
||||
output.showing_reblogs = relationship.showing_reblogs
|
||||
output.subscribed = relationship.subscribing
|
||||
output.relationship = relationship
|
||||
}
|
||||
|
||||
output.allow_following_move = data.pleroma.allow_following_move
|
||||
|
@ -138,16 +132,10 @@ export const parseUser = (data) => {
|
|||
|
||||
output.statusnet_profile_url = data.statusnet_profile_url
|
||||
|
||||
output.statusnet_blocking = data.statusnet_blocking
|
||||
|
||||
output.is_local = data.is_local
|
||||
output.role = data.role
|
||||
output.show_role = data.show_role
|
||||
|
||||
output.follows_you = data.follows_you
|
||||
|
||||
output.muted = data.muted
|
||||
|
||||
if (data.rights) {
|
||||
output.rights = {
|
||||
moderator: data.rights.delete_others_notice,
|
||||
|
@ -161,10 +149,16 @@ export const parseUser = (data) => {
|
|||
output.hide_follows_count = data.hide_follows_count
|
||||
output.hide_followers_count = data.hide_followers_count
|
||||
output.background_image = data.background_image
|
||||
// on mastoapi this info is contained in a "relationship"
|
||||
output.following = data.following
|
||||
// Websocket token
|
||||
output.token = data.token
|
||||
|
||||
// Convert relationsip data to expected format
|
||||
output.relationship = {
|
||||
muting: data.muted,
|
||||
blocking: data.statusnet_blocking,
|
||||
followed_by: data.follows_you,
|
||||
following: data.following
|
||||
}
|
||||
}
|
||||
|
||||
output.created_at = new Date(data.created_at)
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => {
|
||||
const fetchRelationship = (attempt, userId, store) => new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
store.state.api.backendInteractor.fetchUser({ id: user.id })
|
||||
.then((user) => store.commit('addNewUsers', [user]))
|
||||
.then(() => resolve([user.following, user.requested, user.locked, attempt]))
|
||||
store.state.api.backendInteractor.fetchUserRelationship({ id: userId })
|
||||
.then((relationship) => {
|
||||
store.commit('updateUserRelationship', [relationship])
|
||||
return relationship
|
||||
})
|
||||
.then((relationship) => resolve([relationship.following, relationship.requested, relationship.locked, attempt]))
|
||||
.catch((e) => reject(e))
|
||||
}, 500)
|
||||
}).then(([following, sent, locked, attempt]) => {
|
||||
if (!following && !(locked && sent) && attempt <= 3) {
|
||||
// If we BE reports that we still not following that user - retry,
|
||||
// increment attempts by one
|
||||
fetchUser(++attempt, user, store)
|
||||
fetchRelationship(++attempt, userId, store)
|
||||
}
|
||||
})
|
||||
|
||||
export const requestFollow = (user, store) => new Promise((resolve, reject) => {
|
||||
store.state.api.backendInteractor.followUser({ id: user.id })
|
||||
export const requestFollow = (userId, store) => new Promise((resolve, reject) => {
|
||||
store.state.api.backendInteractor.followUser({ id: userId })
|
||||
.then((updated) => {
|
||||
store.commit('updateUserRelationship', [updated])
|
||||
|
||||
if (updated.following || (user.locked && user.requested)) {
|
||||
if (updated.following || (updated.locked && updated.requested)) {
|
||||
// If we get result immediately or the account is locked, just stop.
|
||||
resolve()
|
||||
return
|
||||
|
@ -31,15 +34,15 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
|
|||
// don't know that yet.
|
||||
// Recursive Promise, it will call itself up to 3 times.
|
||||
|
||||
return fetchUser(1, user, store)
|
||||
return fetchRelationship(1, updated, store)
|
||||
.then(() => {
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export const requestUnfollow = (user, store) => new Promise((resolve, reject) => {
|
||||
store.state.api.backendInteractor.unfollowUser({ id: user.id })
|
||||
export const requestUnfollow = (userId, store) => new Promise((resolve, reject) => {
|
||||
store.state.api.backendInteractor.unfollowUser({ id: userId })
|
||||
.then((updated) => {
|
||||
store.commit('updateUserRelationship', [updated])
|
||||
resolve({
|
||||
|
|
|
@ -19,6 +19,7 @@ const actions = {
|
|||
|
||||
const testGetters = {
|
||||
findUser: state => getters.findUser(state.users),
|
||||
relationship: state => getters.relationship(state.users),
|
||||
mergedConfig: state => ({
|
||||
colors: '',
|
||||
highlight: {},
|
||||
|
@ -96,7 +97,8 @@ const externalProfileStore = new Vuex.Store({
|
|||
credentials: ''
|
||||
},
|
||||
usersObject: { 100: extUser },
|
||||
users: [extUser]
|
||||
users: [extUser],
|
||||
relationships: {}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -164,7 +166,8 @@ const localProfileStore = new Vuex.Store({
|
|||
credentials: ''
|
||||
},
|
||||
usersObject: { 100: localUser, 'testuser': localUser },
|
||||
users: [localUser]
|
||||
users: [localUser],
|
||||
relationships: {}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -18,20 +18,6 @@ describe('The users module', () => {
|
|||
expect(state.users).to.eql([user])
|
||||
expect(state.users[0].name).to.eql('Dude')
|
||||
})
|
||||
|
||||
it('sets a mute bit on users', () => {
|
||||
const state = cloneDeep(defaultState)
|
||||
const user = { id: '1', name: 'Guy' }
|
||||
|
||||
mutations.addNewUsers(state, [user])
|
||||
mutations.setMuted(state, { user, muted: true })
|
||||
|
||||
expect(user.muted).to.eql(true)
|
||||
|
||||
mutations.setMuted(state, { user, muted: false })
|
||||
|
||||
expect(user.muted).to.eql(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('findUser', () => {
|
||||
|
|
Loading…
Reference in a new issue