fix(xo-server/subjects/addToArraySet): dont erase previous values (#5269)
Prior to this change, adding a value to an existing set that already contains that value would replace the whole set with a new one containing only that value.
This commit is contained in:
parent
626e2fcb12
commit
3a0cc0d6f6
@ -1,5 +1,5 @@
|
||||
import createLogger from '@xen-orchestra/log'
|
||||
import { filter, includes } from 'lodash'
|
||||
import { filter } from 'lodash'
|
||||
import { ignoreErrors } from 'promise-toolbox'
|
||||
import { hash, needsRehash, verify } from 'hashy'
|
||||
import { invalidCredentials, noSuchObject } from 'xo-common/api-errors'
|
||||
@ -14,7 +14,7 @@ import { forEach, isEmpty, lightSet, mapToArray } from '../utils'
|
||||
const log = createLogger('xo:xo-mixins:subjects')
|
||||
|
||||
const addToArraySet = (set, value) =>
|
||||
set && !includes(set, value) ? set.concat(value) : [value]
|
||||
set !== undefined ? (set.includes(value) ? set : set.concat(value)) : [value]
|
||||
const removeFromArraySet = (set, value) =>
|
||||
set && filter(set, current => current !== value)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user