mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 08:20:39 +00:00
Write email fix (#2890)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
eb25bd2d3c
commit
293d56f4a2
plugins/gmail-resources/src
@ -52,7 +52,13 @@
|
||||
attachedTo: { $in: contacts.map((p) => p._id) }
|
||||
},
|
||||
(res) => {
|
||||
channels = res
|
||||
const map = new Map()
|
||||
for (const channel of res) {
|
||||
if (!map.has(channel.attachedTo)) {
|
||||
map.set(channel.attachedTo, channel)
|
||||
}
|
||||
}
|
||||
channels = Array.from(map.values())
|
||||
}
|
||||
)
|
||||
let channels: Channel[] = []
|
||||
@ -258,15 +264,15 @@
|
||||
<div class="buttons-group">
|
||||
<div class="flex-grow flex-col">
|
||||
<Label label={plugin.string.NewMessage} />
|
||||
<span class="content-accent-color">
|
||||
<div class="content-accent-color targets">
|
||||
<b>
|
||||
{#each channels as channel, i}
|
||||
<div>
|
||||
{getName(channel)}
|
||||
</div>
|
||||
{/each}
|
||||
</b></span
|
||||
>
|
||||
</b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons-group small-gap">
|
||||
@ -341,6 +347,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
.targets {
|
||||
max-height: 10rem;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.input {
|
||||
overflow: auto;
|
||||
padding: 1rem;
|
||||
|
@ -42,9 +42,17 @@ export async function checkHasEmail (doc: Doc | Doc[] | undefined): Promise<bool
|
||||
if (doc === undefined) return false
|
||||
const client = getClient()
|
||||
const arr = Array.isArray(doc) ? doc.map((p) => p._id) : [doc._id]
|
||||
const res = await client.findAll(contact.class.Channel, {
|
||||
provider: contact.channelProvider.Email,
|
||||
attachedTo: { $in: arr }
|
||||
})
|
||||
return res.length === arr.length
|
||||
const res = await client.findAll(
|
||||
contact.class.Channel,
|
||||
{
|
||||
provider: contact.channelProvider.Email,
|
||||
attachedTo: { $in: arr }
|
||||
},
|
||||
{ projection: { _id: 1, attachedTo: 1 } }
|
||||
)
|
||||
const set = new Set(res.map((p) => p.attachedTo))
|
||||
for (const val of arr) {
|
||||
if (!set.has(val)) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user