mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-08 02:37:44 +02:00
Fix directs order (#9885)
This commit is contained in:
@@ -116,9 +116,6 @@
|
||||
{ type: communication.type.Direct, order: 2 }
|
||||
],
|
||||
fixedTypes: [chat.masterTag.Thread, communication.type.Direct],
|
||||
specialSorting: {
|
||||
[communication.type.Direct]: 'alphabetical'
|
||||
},
|
||||
allowCreate: true,
|
||||
defaultSorting: 'recent',
|
||||
lookback: '2w',
|
||||
|
||||
@@ -380,6 +380,37 @@ async function OnCardUpdate (ctx: TxUpdateDoc<Card>[], control: TriggerControl):
|
||||
})
|
||||
}
|
||||
|
||||
res.push(...(await updatePeers(control, doc, updateTx)))
|
||||
return res
|
||||
}
|
||||
|
||||
async function updatePeers (control: TriggerControl, doc: Card, updateTx: TxUpdateDoc<Card>): Promise<Tx[]> {
|
||||
if (updateTx.space === core.space.DerivedTx) return []
|
||||
const isDirect = control.hierarchy.isDerived(doc._class, communication.type.Direct)
|
||||
const isThreadFromDirect = (doc.parentInfo ?? []).some((it) =>
|
||||
control.hierarchy.isDerived(it._class, communication.type.Direct)
|
||||
)
|
||||
|
||||
if (!isDirect && !isThreadFromDirect) return []
|
||||
|
||||
delete updateTx.operations.title
|
||||
delete updateTx.operations.parentInfo
|
||||
delete updateTx.operations.parent
|
||||
delete updateTx.operations.$inc
|
||||
|
||||
const peers = (
|
||||
(
|
||||
await control.domainRequest(control.ctx, 'communication' as OperationDomain, {
|
||||
findPeers: { params: { kind: 'card', cardId: doc._id } }
|
||||
})
|
||||
).value as CardPeer[]
|
||||
).flatMap((it) => it.members)
|
||||
|
||||
const res: Tx[] = []
|
||||
for (const peer of peers) {
|
||||
res.push(control.txFactory.createTxUpdateDoc(doc._class, peer.extra.space, peer.cardId, updateTx.operations))
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user