diff --git a/plugins/gmail-resources/src/components/NewMessages.svelte b/plugins/gmail-resources/src/components/NewMessages.svelte
index 70406f7937..6af812be1a 100644
--- a/plugins/gmail-resources/src/components/NewMessages.svelte
+++ b/plugins/gmail-resources/src/components/NewMessages.svelte
@@ -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 @@
@@ -341,6 +347,11 @@
}
}
+ .targets {
+ max-height: 10rem;
+ overflow-x: auto;
+ }
+
.input {
overflow: auto;
padding: 1rem;
diff --git a/plugins/gmail-resources/src/utils.ts b/plugins/gmail-resources/src/utils.ts
index 0e57cf7bd1..060a83ce1c 100644
--- a/plugins/gmail-resources/src/utils.ts
+++ b/plugins/gmail-resources/src/utils.ts
@@ -42,9 +42,17 @@ export async function checkHasEmail (doc: Doc | Doc[] | undefined): Promise 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
}