mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-29 09:09:15 +03:00
prevent multiple attempts to update (#5958)
This commit is contained in:
parent
8003611c37
commit
02f965d8cb
@ -15,7 +15,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import contact from '@hcengineering/contact'
|
import contact from '@hcengineering/contact'
|
||||||
import { AccountArrayEditor } from '@hcengineering/contact-resources'
|
import { AccountArrayEditor } from '@hcengineering/contact-resources'
|
||||||
import core, { Account, Ref, type SpaceType, type SpaceTypeDescriptor } from '@hcengineering/core'
|
import core, { Account, reduceCalls, Ref, type SpaceType, type SpaceTypeDescriptor } from '@hcengineering/core'
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
import { ButtonIcon, IconSquareExpand, Label, ModernButton, ModernEditbox, TextArea, Toggle } from '@hcengineering/ui'
|
import { ButtonIcon, IconSquareExpand, Label, ModernButton, ModernEditbox, TextArea, Toggle } from '@hcengineering/ui'
|
||||||
|
|
||||||
@ -53,14 +53,14 @@
|
|||||||
await client.update(type, { [field]: value })
|
await client.update(type, { [field]: value })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeMembers (members: Ref<Account>[]): Promise<void> {
|
const changeMembers = reduceCalls(async function changeMembers (members: Ref<Account>[]): Promise<void> {
|
||||||
if (disabled || type === undefined) {
|
if (disabled || type === undefined) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const push = new Set<Ref<Account>>(members)
|
const push = new Set<Ref<Account>>(members)
|
||||||
const pull = new Set<Ref<Account>>()
|
const pull = new Set<Ref<Account>>()
|
||||||
for (const member of type.members ?? []) {
|
for (const member of (type.members ?? []).filter((it, idx, arr) => arr.indexOf(it) === idx)) {
|
||||||
if (!push.has(member)) {
|
if (!push.has(member)) {
|
||||||
pull.add(member)
|
pull.add(member)
|
||||||
} else {
|
} else {
|
||||||
@ -78,7 +78,7 @@
|
|||||||
ops.update(type, { $pull: { members: pullMem } })
|
ops.update(type, { $pull: { members: pullMem } })
|
||||||
}
|
}
|
||||||
await ops.commit()
|
await ops.commit()
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if descriptor !== undefined}
|
{#if descriptor !== undefined}
|
||||||
|
Loading…
Reference in New Issue
Block a user