aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShpuld Shpuldson <shp@cock.li>2020-04-24 18:53:17 +0300
committerShpuld Shpuldson <shp@cock.li>2020-04-24 18:53:17 +0300
commitaf9492977aaa10903d54add3187b5cf9d9a00d6c (patch)
tree09ecf8ce1238d0daab75b0dc26e3e5c1d96f16a3 /src
parentf6fce92cf7a463fbdf270d494404dca5aae06045 (diff)
add back mute prediction, add getter for relationships
Diffstat (limited to 'src')
-rw-r--r--src/components/block_card/block_card.js2
-rw-r--r--src/components/follow_card/follow_card.js2
-rw-r--r--src/components/mute_card/mute_card.js2
-rw-r--r--src/components/notification/notification.js2
-rw-r--r--src/components/status/status.js2
-rw-r--r--src/components/user_card/user_card.js2
-rw-r--r--src/components/user_settings/user_settings.js4
-rw-r--r--src/modules/users.js12
8 files changed, 20 insertions, 8 deletions
diff --git a/src/components/block_card/block_card.js b/src/components/block_card/block_card.js
index 659c75d8..0bf4e37b 100644
--- a/src/components/block_card/block_card.js
+++ b/src/components/block_card/block_card.js
@@ -12,7 +12,7 @@ const BlockCard = {
return this.$store.getters.findUser(this.userId)
},
relationship () {
- return this.$store.state.users.relationships[this.userId] || {}
+ return this.$store.getters.relationship(this.userId)
},
blocked () {
return this.relationship.blocking
diff --git a/src/components/follow_card/follow_card.js b/src/components/follow_card/follow_card.js
index 620ae7fd..6dcb6d47 100644
--- a/src/components/follow_card/follow_card.js
+++ b/src/components/follow_card/follow_card.js
@@ -20,7 +20,7 @@ const FollowCard = {
return this.$store.state.users.currentUser
},
relationship () {
- return this.$store.state.users.relationships[this.user.id]
+ return this.$store.getters.relationship(this.user.id)
}
}
}
diff --git a/src/components/mute_card/mute_card.js b/src/components/mute_card/mute_card.js
index be528d37..cbec0e9b 100644
--- a/src/components/mute_card/mute_card.js
+++ b/src/components/mute_card/mute_card.js
@@ -12,7 +12,7 @@ const MuteCard = {
return this.$store.getters.findUser(this.userId)
},
relationship () {
- return this.$store.state.users.relationships[this.userId]
+ return this.$store.getters.relationship(this.userId)
},
muted () {
return this.relationship.muting
diff --git a/src/components/notification/notification.js b/src/components/notification/notification.js
index 09554f54..ff1c2817 100644
--- a/src/components/notification/notification.js
+++ b/src/components/notification/notification.js
@@ -56,7 +56,7 @@ const Notification = {
return this.generateUserProfileLink(this.targetUser)
},
needMute () {
- return (this.$store.state.users.relationships[this.user.id] || {}).muting
+ return this.$store.getters.relationship(this.user.id).muting
}
}
}
diff --git a/src/components/status/status.js b/src/components/status/status.js
index a73e3ae2..a36de028 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -119,7 +119,7 @@ const Status = {
return hits
},
muted () {
- const relationship = this.$store.state.users.relationships[this.status.user.id] || {}
+ const relationship = this.$store.getters.relationship(this.userId)
return !this.unmuted && (
(!(this.inProfile && this.status.user.id === this.profileUserId) && relationship.muting) ||
(!this.inConversation && this.status.thread_muted) ||
diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js
index fb3cfebc..8e6b9d7f 100644
--- a/src/components/user_card/user_card.js
+++ b/src/components/user_card/user_card.js
@@ -25,7 +25,7 @@ export default {
return this.$store.getters.findUser(this.userId)
},
relationship () {
- return this.$store.state.users.relationships[this.userId] || {}
+ return this.$store.getters.relationship(this.userId)
},
classes () {
return [{
diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index adfab8fa..5338c974 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -351,13 +351,13 @@ const UserSettings = {
},
filterUnblockedUsers (userIds) {
return reject(userIds, (userId) => {
- const relationship = this.$store.state.users.relationships[userId] || {}
+ 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 relationship = this.$store.state.users.relationships[userId] || {}
+ const relationship = this.$store.getters.relationship(this.userId)
return relationship.muting || userId === this.$store.state.users.currentUser.id
})
},
diff --git a/src/modules/users.js b/src/modules/users.js
index 6b19fc97..fb04ebd3 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -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]))
}
@@ -227,6 +236,9 @@ export const getters = {
return state.usersObject[query.toLowerCase()]
}
return result
+ },
+ relationship: state => id => {
+ return state.relationships[id] || { id, loading: true }
}
}