diff options
| author | Shpuld Shpuldson <shp@cock.li> | 2020-06-27 12:26:19 +0300 |
|---|---|---|
| committer | Shpuld Shpuldson <shp@cock.li> | 2020-06-27 12:26:19 +0300 |
| commit | 5ab62c4cb8bc2ccf718d0b60749bcc03fba54784 (patch) | |
| tree | 43fb3643d1be79b288de469a96b19cb019b50480 /src/modules/users.js | |
| parent | a2c5175d14b322062f8fc07b11a6a45f1d5aba4f (diff) | |
| parent | 4d52b8bf56c44a217b2cc97414bf13104691d7f9 (diff) | |
make use of api/v1/instance
Diffstat (limited to 'src/modules/users.js')
| -rw-r--r-- | src/modules/users.js | 13 |
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 |
