stop using vue.set
This commit is contained in:
parent
fca885e665
commit
905b9771ec
11 changed files with 52 additions and 64 deletions
|
|
@ -1,7 +1,6 @@
|
|||
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
|
||||
import oauthApi from '../services/new_api/oauth.js'
|
||||
import { compact, map, each, mergeWith, last, concat, uniq, isArray } from 'lodash'
|
||||
import { set } from 'vue'
|
||||
import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
|
||||
|
||||
// TODO: Unify with mergeOrAdd in statuses.js
|
||||
|
|
@ -15,9 +14,9 @@ export const mergeOrAdd = (arr, obj, item) => {
|
|||
} else {
|
||||
// This is a new item, prepare it
|
||||
arr.push(item)
|
||||
set(obj, item.id, item)
|
||||
obj[item.id] = item
|
||||
if (item.screen_name && !item.screen_name.includes('@')) {
|
||||
set(obj, item.screen_name.toLowerCase(), item)
|
||||
obj[item.screen_name.toLowerCase()] = item
|
||||
}
|
||||
return { item, new: true }
|
||||
}
|
||||
|
|
@ -103,23 +102,23 @@ export const mutations = {
|
|||
const user = state.usersObject[id]
|
||||
const tags = user.tags || []
|
||||
const newTags = tags.concat([tag])
|
||||
set(user, 'tags', newTags)
|
||||
user['tags'] = newTags
|
||||
},
|
||||
untagUser (state, { user: { id }, tag }) {
|
||||
const user = state.usersObject[id]
|
||||
const tags = user.tags || []
|
||||
const newTags = tags.filter(t => t !== tag)
|
||||
set(user, 'tags', newTags)
|
||||
user['tags'] = newTags
|
||||
},
|
||||
updateRight (state, { user: { id }, right, value }) {
|
||||
const user = state.usersObject[id]
|
||||
let newRights = user.rights
|
||||
newRights[right] = value
|
||||
set(user, 'rights', newRights)
|
||||
user['rights'] = newRights
|
||||
},
|
||||
updateActivationStatus (state, { user: { id }, deactivated }) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'deactivated', deactivated)
|
||||
user['deactivated'] = deactivated
|
||||
},
|
||||
setCurrentUser (state, user) {
|
||||
state.lastLoginName = user.screen_name
|
||||
|
|
@ -148,26 +147,26 @@ export const mutations = {
|
|||
clearFriends (state, userId) {
|
||||
const user = state.usersObject[userId]
|
||||
if (user) {
|
||||
set(user, 'friendIds', [])
|
||||
user['friendIds'] = []
|
||||
}
|
||||
},
|
||||
clearFollowers (state, userId) {
|
||||
const user = state.usersObject[userId]
|
||||
if (user) {
|
||||
set(user, 'followerIds', [])
|
||||
user['followerIds'] = []
|
||||
}
|
||||
},
|
||||
addNewUsers (state, users) {
|
||||
each(users, (user) => {
|
||||
if (user.relationship) {
|
||||
set(state.relationships, user.relationship.id, user.relationship)
|
||||
state.relationships[user.relationship.id] = user.relationship
|
||||
}
|
||||
mergeOrAdd(state.users, state.usersObject, user)
|
||||
})
|
||||
},
|
||||
updateUserRelationship (state, relationships) {
|
||||
relationships.forEach((relationship) => {
|
||||
set(state.relationships, relationship.id, relationship)
|
||||
state.relationships[relationship.id] = relationship
|
||||
})
|
||||
},
|
||||
saveBlockIds (state, blockIds) {
|
||||
|
|
@ -222,7 +221,7 @@ export const mutations = {
|
|||
},
|
||||
setColor (state, { user: { id }, highlighted }) {
|
||||
const user = state.usersObject[id]
|
||||
set(user, 'highlight', highlighted)
|
||||
user['highlight'] = highlighted
|
||||
},
|
||||
signUpPending (state) {
|
||||
state.signUpPending = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue