aboutsummaryrefslogtreecommitdiff
path: root/src/modules/users.js
diff options
context:
space:
mode:
authorShpuld Shpuldson <shp@cock.li>2020-06-27 12:10:02 +0300
committerShpuld Shpuldson <shp@cock.li>2020-06-27 12:10:02 +0300
commit58f9c1cc4932b8c2c3450aa215f5ebab6de1a4d7 (patch)
tree73389d25a7093eff4c19b84948149505e8854e10 /src/modules/users.js
parent504d48fc5a707a60f5c7f5d5cf92ab2af762bb2e (diff)
parent3113d904b921b1258c3709101d7e688767037079 (diff)
fix conflict in after_store
Diffstat (limited to 'src/modules/users.js')
-rw-r--r--src/modules/users.js13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/modules/users.js b/src/modules/users.js
index 5e32bb49..68d02931 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -1,6 +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, merge, last, concat, uniq } from 'lodash'
+import { compact, map, each, mergeWith, last, concat, uniq, isArray } from 'lodash'
import { set } from 'vue'
import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
@@ -10,7 +10,7 @@ export const mergeOrAdd = (arr, obj, item) => {
const oldItem = obj[item.id]
if (oldItem) {
// We already have this, so only merge the new info.
- merge(oldItem, item)
+ mergeWith(oldItem, item, mergeArrayLength)
return { item: oldItem, new: false }
} else {
// This is a new item, prepare it
@@ -23,6 +23,13 @@ export const mergeOrAdd = (arr, obj, item) => {
}
}
+const mergeArrayLength = (oldValue, newValue) => {
+ if (isArray(oldValue) && isArray(newValue)) {
+ oldValue.length = newValue.length
+ return mergeWith(oldValue, newValue, mergeArrayLength)
+ }
+}
+
const getNotificationPermission = () => {
const Notification = window.Notification
@@ -116,7 +123,7 @@ export const mutations = {
},
setCurrentUser (state, user) {
state.lastLoginName = user.screen_name
- state.currentUser = merge(state.currentUser || {}, user)
+ state.currentUser = mergeWith(state.currentUser || {}, user, mergeArrayLength)
},
clearCurrentUser (state) {
state.currentUser = false