mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-09 09:20:54 +00:00
uberf-11415: fix formatting
Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
parent
33411b6253
commit
668675b080
@ -256,7 +256,10 @@ export async function combineActivityMessages (
|
||||
|
||||
const result: Array<DisplayActivityMessage | undefined> = [...uncombined]
|
||||
|
||||
const groupedByType: Map<string, DocUpdateMessage[]> = await groupByArrayAsync(docUpdateMessages, getDocUpdateMessageKey)
|
||||
const groupedByType: Map<string, DocUpdateMessage[]> = await groupByArrayAsync(
|
||||
docUpdateMessages,
|
||||
getDocUpdateMessageKey
|
||||
)
|
||||
|
||||
for (const [, groupedMessages] of groupedByType) {
|
||||
const cantMerge = groupedMessages.filter(
|
||||
|
@ -17,11 +17,7 @@
|
||||
import { DocAttributeUpdates, DocUpdateMessage } from '@hcengineering/activity'
|
||||
import { Employee, Person } from '@hcengineering/contact'
|
||||
import { AccountUuid, notEmpty, PersonId } from '@hcengineering/core'
|
||||
import {
|
||||
PersonPresenter,
|
||||
employeeByAccountStore,
|
||||
employeeByPersonIdStore
|
||||
} from '@hcengineering/contact-resources'
|
||||
import { PersonPresenter, employeeByAccountStore, employeeByPersonIdStore } from '@hcengineering/contact-resources'
|
||||
import { ChunterSpace } from '@hcengineering/chunter'
|
||||
import { Label } from '@hcengineering/ui'
|
||||
import view from '@hcengineering/view'
|
||||
|
@ -19,10 +19,7 @@
|
||||
import { AttachmentDocList, AttachmentImageSize } from '@hcengineering/attachment-resources'
|
||||
import chunter, { ChatMessage, ChatMessageViewlet } from '@hcengineering/chunter'
|
||||
import contact, { getCurrentEmployee, Person, SocialIdentity } from '@hcengineering/contact'
|
||||
import {
|
||||
getPersonByPersonId,
|
||||
getSocialIdByPersonId
|
||||
} from '@hcengineering/contact-resources'
|
||||
import { getPersonByPersonId, getSocialIdByPersonId } from '@hcengineering/contact-resources'
|
||||
import { Class, Doc, Markup, Ref, Space, WithLookup } from '@hcengineering/core'
|
||||
import { getClient, MessageViewer, pendingCreatedDocs } from '@hcengineering/presentation'
|
||||
import { EmptyMarkup } from '@hcengineering/text'
|
||||
|
@ -80,7 +80,7 @@
|
||||
author = $employeeByPersonIdStore.get(socialId)
|
||||
|
||||
if (author === undefined) {
|
||||
author = await getPersonByPersonId(socialId) ?? undefined
|
||||
author = (await getPersonByPersonId(socialId)) ?? undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,29 +43,20 @@ export default class ContactCacheStoreManager {
|
||||
}
|
||||
|
||||
private readonly _personRefByPersonIdStoreBase = writable<Map<PersonId, Ref<Person> | null>>(new Map())
|
||||
private readonly _personRefByPersonIdStore = derived(
|
||||
[this._personRefByPersonIdStoreBase],
|
||||
([store]) => {
|
||||
return new Map(Array.from(store.entries()).filter(notEmptyValue))
|
||||
}
|
||||
)
|
||||
private readonly _personRefByPersonIdStore = derived([this._personRefByPersonIdStoreBase], ([store]) => {
|
||||
return new Map(Array.from(store.entries()).filter(notEmptyValue))
|
||||
})
|
||||
|
||||
private readonly _personByPersonIdStoreBase = writable<Map<PersonId, Readonly<Person> | null>>(new Map())
|
||||
private readonly _personByPersonIdStore = derived(
|
||||
[this._personByPersonIdStoreBase],
|
||||
([store]) => {
|
||||
return new Map(Array.from(store.entries()).filter(notEmptyValue))
|
||||
}
|
||||
)
|
||||
private readonly _personByPersonIdStore = derived([this._personByPersonIdStoreBase], ([store]) => {
|
||||
return new Map(Array.from(store.entries()).filter(notEmptyValue))
|
||||
})
|
||||
|
||||
private readonly _personByPersonRefStoreBase = writable<Map<Ref<Person>, Readonly<Person> | null>>(new Map())
|
||||
|
||||
private readonly _personByPersonRefStore = derived(
|
||||
[this._personByPersonRefStoreBase],
|
||||
([store]) => {
|
||||
return new Map(Array.from(store.entries()).filter(notEmptyValue))
|
||||
}
|
||||
)
|
||||
private readonly _personByPersonRefStore = derived([this._personByPersonRefStoreBase], ([store]) => {
|
||||
return new Map(Array.from(store.entries()).filter(notEmptyValue))
|
||||
})
|
||||
|
||||
public getPersonRefByPersonIdStore (personIds: PersonId[]): Readable<Map<PersonId, Ref<Person>>> {
|
||||
if (personIds.length > 0) {
|
||||
|
@ -86,9 +86,7 @@
|
||||
void update?.()
|
||||
})
|
||||
|
||||
$: employees = (value ?? [])
|
||||
.map((p) => $employeeRefByAccountUuidStore.get(p))
|
||||
.filter(notEmpty)
|
||||
$: employees = (value ?? []).map((p) => $employeeRefByAccountUuidStore.get(p)).filter(notEmpty)
|
||||
$: docQuery =
|
||||
excludeItems.length === 0 && includeItems.length === 0
|
||||
? {}
|
||||
|
@ -37,9 +37,7 @@
|
||||
? {}
|
||||
: {
|
||||
_id: {
|
||||
$in: include
|
||||
.map((personId) => $employeeByPersonIdStore.get(personId)?._id)
|
||||
.filter(notEmpty)
|
||||
$in: include.map((personId) => $employeeByPersonIdStore.get(personId)?._id).filter(notEmpty)
|
||||
}
|
||||
}
|
||||
$: selectedEmp = value != null ? $employeeByPersonIdStore.get(value)?._id : value
|
||||
|
@ -88,10 +88,7 @@
|
||||
</div>
|
||||
<Button
|
||||
on:click={() => {
|
||||
dispatch(
|
||||
'close',
|
||||
memberAccountsToAdd
|
||||
)
|
||||
dispatch('close', memberAccountsToAdd)
|
||||
}}
|
||||
label={presentation.string.Add}
|
||||
/>
|
||||
|
@ -79,10 +79,11 @@
|
||||
|
||||
$: personByRefStore = getPersonByPersonRefStore(value != null ? [value] : [])
|
||||
|
||||
const updateSelected = reduceCalls(async function (value: Ref<Person> | null | undefined, personByRefStore: Map<Ref<Person>, Readonly<Person>>) {
|
||||
selected = value
|
||||
? personByRefStore.get(value) ?? undefined
|
||||
: undefined
|
||||
const updateSelected = reduceCalls(async function (
|
||||
value: Ref<Person> | null | undefined,
|
||||
personByRefStore: Map<Ref<Person>, Readonly<Person>>
|
||||
) {
|
||||
selected = value ? personByRefStore.get(value) ?? undefined : undefined
|
||||
})
|
||||
|
||||
$: void updateSelected(value, $personByRefStore)
|
||||
|
@ -34,9 +34,11 @@
|
||||
const objectArray = Array.isArray(object) ? object : [object]
|
||||
const dispatch = createEventDispatcher()
|
||||
let creators: Ref<Person>[]
|
||||
$: void getPersonRefsByPersonIds(Array.from(new Set(objectArray.map((obj) => obj.createdBy).filter(notEmpty)))).then((refs) => {
|
||||
creators = Array.from(refs.values())
|
||||
})
|
||||
$: void getPersonRefsByPersonIds(Array.from(new Set(objectArray.map((obj) => obj.createdBy).filter(notEmpty)))).then(
|
||||
(refs) => {
|
||||
creators = Array.from(refs.values())
|
||||
}
|
||||
)
|
||||
|
||||
$: canDelete =
|
||||
(skipCheck ||
|
||||
|
@ -30,7 +30,7 @@
|
||||
const client = getClient()
|
||||
const h = client.getHierarchy()
|
||||
|
||||
$: person = typeof value === 'string' ? ($employeeByIdStore.get(value as Ref<Employee>)) : (value as Person)
|
||||
$: person = typeof value === 'string' ? $employeeByIdStore.get(value as Ref<Employee>) : (value as Person)
|
||||
$: employeeValue = person != null ? h.as(person, contact.mixin.Employee) : undefined
|
||||
$: active = employeeValue?.active ?? false
|
||||
</script>
|
||||
|
@ -40,17 +40,19 @@
|
||||
let update: (() => Promise<void>) | undefined
|
||||
|
||||
$: valueByPersonRef = new Map<Ref<Employee>, PersonId>(
|
||||
value.map((p) => {
|
||||
const employee = $employeeByPersonIdStore.get(p)
|
||||
const ref = employee?._id
|
||||
value
|
||||
.map((p) => {
|
||||
const employee = $employeeByPersonIdStore.get(p)
|
||||
const ref = employee?._id
|
||||
|
||||
if (ref == null) {
|
||||
console.error('Employee not found for social id', p)
|
||||
return null
|
||||
}
|
||||
if (ref == null) {
|
||||
console.error('Employee not found for social id', p)
|
||||
return null
|
||||
}
|
||||
|
||||
return [ref, p] as const
|
||||
}).filter(notEmpty)
|
||||
return [ref, p] as const
|
||||
})
|
||||
.filter(notEmpty)
|
||||
)
|
||||
|
||||
function onUpdate (evt: CustomEvent<Ref<Employee>[]>): void {
|
||||
|
@ -393,47 +393,58 @@ onClient(() => {
|
||||
channelProviders.set(res)
|
||||
})
|
||||
|
||||
employeesQuery.query(contact.mixin.Employee, { active: { $in: [true, false] } }, (res) => {
|
||||
const personIdToEmployee = new Map<PersonId, Employee>()
|
||||
const socialKeyToEmployee = new Map<string, Employee>()
|
||||
for (const employee of res) {
|
||||
// warmup persons cache with employees
|
||||
contactCache.fillCachesForPersonRef(employee._id, employee)
|
||||
employeesQuery.query(
|
||||
contact.mixin.Employee,
|
||||
{ active: { $in: [true, false] } },
|
||||
(res) => {
|
||||
const personIdToEmployee = new Map<PersonId, Employee>()
|
||||
const socialKeyToEmployee = new Map<string, Employee>()
|
||||
for (const employee of res) {
|
||||
// warmup persons cache with employees
|
||||
contactCache.fillCachesForPersonRef(employee._id, employee)
|
||||
|
||||
for (const socialId of (employee.$lookup?.socialIds ?? []) as SocialIdentity[]) {
|
||||
personIdToEmployee.set(socialId._id, employee)
|
||||
socialKeyToEmployee.set(socialId.key, employee)
|
||||
}
|
||||
}
|
||||
employeeByPersonIdStore.set(personIdToEmployee)
|
||||
employeeBySocialKeyStore.set(socialKeyToEmployee)
|
||||
primarySocialIdByEmployeeRefStore.set(new Map(res.map((e) => {
|
||||
const socialIds = (e.$lookup?.socialIds ?? []) as SocialIdentity[]
|
||||
const primaryId = socialIds.length !== 0 ? pickPrimarySocialId(socialIds) : undefined
|
||||
if (primaryId === undefined) {
|
||||
return null
|
||||
for (const socialId of (employee.$lookup?.socialIds ?? []) as SocialIdentity[]) {
|
||||
personIdToEmployee.set(socialId._id, employee)
|
||||
socialKeyToEmployee.set(socialId.key, employee)
|
||||
}
|
||||
}
|
||||
employeeByPersonIdStore.set(personIdToEmployee)
|
||||
employeeBySocialKeyStore.set(socialKeyToEmployee)
|
||||
primarySocialIdByEmployeeRefStore.set(
|
||||
new Map(
|
||||
res
|
||||
.map((e) => {
|
||||
const socialIds = (e.$lookup?.socialIds ?? []) as SocialIdentity[]
|
||||
const primaryId = socialIds.length !== 0 ? pickPrimarySocialId(socialIds) : undefined
|
||||
if (primaryId === undefined) {
|
||||
return null
|
||||
}
|
||||
|
||||
return [e._id, primaryId._id] as const
|
||||
}).filter(notEmpty)))
|
||||
|
||||
// Remove lookups before storing the map as the interface doesn't expose it anyways
|
||||
for (const employee of res) {
|
||||
delete employee.$lookup
|
||||
}
|
||||
employeeByIdStore.set(toIdMap(res))
|
||||
|
||||
// We may need to extend this later with guests and github users
|
||||
employeeRefByAccountUuidStore.set(
|
||||
new Map(
|
||||
res.filter((p) => p.active && p.personUuid != null).map((p) => [p.personUuid as AccountUuid, p._id] as const)
|
||||
return [e._id, primaryId._id] as const
|
||||
})
|
||||
.filter(notEmpty)
|
||||
)
|
||||
)
|
||||
)
|
||||
}, {
|
||||
lookup: {
|
||||
_id: { socialIds: contact.class.SocialIdentity }
|
||||
|
||||
// Remove lookups before storing the map as the interface doesn't expose it anyways
|
||||
for (const employee of res) {
|
||||
delete employee.$lookup
|
||||
}
|
||||
employeeByIdStore.set(toIdMap(res))
|
||||
|
||||
// We may need to extend this later with guests and github users
|
||||
employeeRefByAccountUuidStore.set(
|
||||
new Map(
|
||||
res.filter((p) => p.active && p.personUuid != null).map((p) => [p.personUuid as AccountUuid, p._id] as const)
|
||||
)
|
||||
)
|
||||
},
|
||||
{
|
||||
lookup: {
|
||||
_id: { socialIds: contact.class.SocialIdentity }
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
const userStatusesQuery = createQuery(true)
|
||||
@ -666,65 +677,68 @@ export function getPermittedPersons (
|
||||
|
||||
const spacesStore = writable<Space[]>([])
|
||||
|
||||
export const permissionsStore = derived([spacesStore, employeeRefByAccountUuidStore], ([spaces, personRefByAccount]) => {
|
||||
const whitelistedSpaces = new Set<Ref<Space>>()
|
||||
const permissionsBySpace: PermissionsBySpace = {}
|
||||
const employeesByPermission: PersonsByPermission = {}
|
||||
const membersBySpace: MembersBySpace = {}
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
export const permissionsStore = derived(
|
||||
[spacesStore, employeeRefByAccountUuidStore],
|
||||
([spaces, personRefByAccount]) => {
|
||||
const whitelistedSpaces = new Set<Ref<Space>>()
|
||||
const permissionsBySpace: PermissionsBySpace = {}
|
||||
const employeesByPermission: PersonsByPermission = {}
|
||||
const membersBySpace: MembersBySpace = {}
|
||||
const client = getClient()
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
for (const s of spaces) {
|
||||
membersBySpace[s._id] = new Set(s.members.map((m) => personRefByAccount.get(m)).filter(notEmpty))
|
||||
if (hierarchy.isDerived(s._class, core.class.TypedSpace)) {
|
||||
const type = client.getModel().findAllSync(core.class.SpaceType, { _id: (s as TypedSpace).type })[0]
|
||||
const mixin = type?.targetClass
|
||||
for (const s of spaces) {
|
||||
membersBySpace[s._id] = new Set(s.members.map((m) => personRefByAccount.get(m)).filter(notEmpty))
|
||||
if (hierarchy.isDerived(s._class, core.class.TypedSpace)) {
|
||||
const type = client.getModel().findAllSync(core.class.SpaceType, { _id: (s as TypedSpace).type })[0]
|
||||
const mixin = type?.targetClass
|
||||
|
||||
if (mixin === undefined) {
|
||||
permissionsBySpace[s._id] = new Set()
|
||||
employeesByPermission[s._id] = {}
|
||||
continue
|
||||
}
|
||||
|
||||
const asMixin = hierarchy.as(s, mixin)
|
||||
const roles = client.getModel().findAllSync(core.class.Role, { attachedTo: type._id })
|
||||
const myRoles = roles.filter((r) => ((asMixin as any)[r._id] ?? []).includes(getCurrentAccount().uuid))
|
||||
permissionsBySpace[s._id] = new Set(myRoles.flatMap((r) => r.permissions))
|
||||
|
||||
employeesByPermission[s._id] = {}
|
||||
|
||||
for (const role of roles) {
|
||||
const assignment: AccountUuid[] = (asMixin as any)[role._id] ?? []
|
||||
|
||||
if (assignment.length === 0) {
|
||||
if (mixin === undefined) {
|
||||
permissionsBySpace[s._id] = new Set()
|
||||
employeesByPermission[s._id] = {}
|
||||
continue
|
||||
}
|
||||
|
||||
for (const permissionId of role.permissions) {
|
||||
if (employeesByPermission[s._id][permissionId] === undefined) {
|
||||
employeesByPermission[s._id][permissionId] = new Set()
|
||||
const asMixin = hierarchy.as(s, mixin)
|
||||
const roles = client.getModel().findAllSync(core.class.Role, { attachedTo: type._id })
|
||||
const myRoles = roles.filter((r) => ((asMixin as any)[r._id] ?? []).includes(getCurrentAccount().uuid))
|
||||
permissionsBySpace[s._id] = new Set(myRoles.flatMap((r) => r.permissions))
|
||||
|
||||
employeesByPermission[s._id] = {}
|
||||
|
||||
for (const role of roles) {
|
||||
const assignment: AccountUuid[] = (asMixin as any)[role._id] ?? []
|
||||
|
||||
if (assignment.length === 0) {
|
||||
continue
|
||||
}
|
||||
|
||||
assignment.forEach((acc) => {
|
||||
const personRef = personRefByAccount.get(acc)
|
||||
if (personRef !== undefined) {
|
||||
employeesByPermission[s._id][permissionId].add(personRef)
|
||||
for (const permissionId of role.permissions) {
|
||||
if (employeesByPermission[s._id][permissionId] === undefined) {
|
||||
employeesByPermission[s._id][permissionId] = new Set()
|
||||
}
|
||||
})
|
||||
|
||||
assignment.forEach((acc) => {
|
||||
const personRef = personRefByAccount.get(acc)
|
||||
if (personRef !== undefined) {
|
||||
employeesByPermission[s._id][permissionId].add(personRef)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
whitelistedSpaces.add(s._id)
|
||||
}
|
||||
} else {
|
||||
whitelistedSpaces.add(s._id)
|
||||
}
|
||||
|
||||
return {
|
||||
ps: permissionsBySpace,
|
||||
ap: employeesByPermission,
|
||||
ms: membersBySpace,
|
||||
whitelist: whitelistedSpaces
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ps: permissionsBySpace,
|
||||
ap: employeesByPermission,
|
||||
ms: membersBySpace,
|
||||
whitelist: whitelistedSpaces
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
const spaceTypesQuery = createQuery(true)
|
||||
const permissionsQuery = createQuery(true)
|
||||
@ -791,7 +805,9 @@ export async function getPersonByPersonRef (personRef: Ref<Person>): Promise<Per
|
||||
return await getPersonByPersonRefBase(client, personRef)
|
||||
}
|
||||
|
||||
export async function getPersonsByPersonRefs (personRefs: Array<Ref<Person>>): Promise<Map<Ref<Person>, Readonly<Person>>> {
|
||||
export async function getPersonsByPersonRefs (
|
||||
personRefs: Array<Ref<Person>>
|
||||
): Promise<Map<Ref<Person>, Readonly<Person>>> {
|
||||
const client = getClient()
|
||||
|
||||
return await getPersonsByPersonRefsBase(client, personRefs)
|
||||
@ -815,6 +831,8 @@ export function getPersonByPersonIdStore (personIds: PersonId[]): Readable<Map<P
|
||||
return contactCacheStoreManager.getPersonByPersonIdStore(personIds)
|
||||
}
|
||||
|
||||
export function getPersonByPersonRefStore (personRefs: Array<Ref<Person>>): Readable<Map<Ref<Person>, Readonly<Person>>> {
|
||||
export function getPersonByPersonRefStore (
|
||||
personRefs: Array<Ref<Person>>
|
||||
): Readable<Map<Ref<Person>, Readonly<Person>>> {
|
||||
return contactCacheStoreManager.getPersonByPersonRefStore(personRefs)
|
||||
}
|
||||
|
@ -212,7 +212,9 @@ export default class ContactCache {
|
||||
const person = this._personByRef.get(ref)
|
||||
if (person == null) return
|
||||
|
||||
const updatedPerson = isUpdateTx(tx) ? TxProcessor.updateDoc2Doc(person, tx) : TxProcessor.updateMixin4Doc(person, tx)
|
||||
const updatedPerson = isUpdateTx(tx)
|
||||
? TxProcessor.updateDoc2Doc(person, tx)
|
||||
: TxProcessor.updateMixin4Doc(person, tx)
|
||||
this._personByRef.set(ref, updatedPerson)
|
||||
const personIds = Array.from(this._personIdsByPersonRef.get(ref) ?? [])
|
||||
for (const personId of personIds) {
|
||||
|
@ -37,7 +37,16 @@ import {
|
||||
} from '@hcengineering/core'
|
||||
import { getMetadata } from '@hcengineering/platform'
|
||||
import { ColorDefinition } from '@hcengineering/ui'
|
||||
import contact, { AvatarProvider, AvatarType, Channel, Contact, Employee, Person, SocialIdentity, SocialIdentityRef } from '.'
|
||||
import contact, {
|
||||
AvatarProvider,
|
||||
AvatarType,
|
||||
Channel,
|
||||
Contact,
|
||||
Employee,
|
||||
Person,
|
||||
SocialIdentity,
|
||||
SocialIdentityRef
|
||||
} from '.'
|
||||
|
||||
import { AVATAR_COLORS, GravatarPlaceholderType } from './types'
|
||||
import ContactCache from './cache'
|
||||
@ -553,17 +562,19 @@ export async function loadCachesForPersonId (client: Client, personId: PersonId)
|
||||
}
|
||||
|
||||
export async function loadCachesForPersonIds (client: Client, personIds: PersonId[]): Promise<void> {
|
||||
const sidObjsMap = toIdMap(await client.findAll(
|
||||
contact.class.SocialIdentity,
|
||||
{
|
||||
_id: { $in: personIds as SocialIdentityRef[] }
|
||||
},
|
||||
{
|
||||
lookup: {
|
||||
attachedTo: contact.class.Person
|
||||
const sidObjsMap = toIdMap(
|
||||
await client.findAll(
|
||||
contact.class.SocialIdentity,
|
||||
{
|
||||
_id: { $in: personIds as SocialIdentityRef[] }
|
||||
},
|
||||
{
|
||||
lookup: {
|
||||
attachedTo: contact.class.Person
|
||||
}
|
||||
}
|
||||
}
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
for (const personId of personIds) {
|
||||
const sidObj = sidObjsMap.get(personId as SocialIdentityRef)
|
||||
@ -589,17 +600,19 @@ export async function loadCachesForPersonRef (client: Client, personRef: Ref<Per
|
||||
}
|
||||
|
||||
export async function loadCachesForPersonRefs (client: Client, personRefs: Array<Ref<Person>>): Promise<void> {
|
||||
const persons = toIdMap(await client.findAll(
|
||||
contact.class.Person,
|
||||
{
|
||||
_id: { $in: personRefs }
|
||||
},
|
||||
{
|
||||
lookup: {
|
||||
_id: { socialIds: contact.class.SocialIdentity }
|
||||
const persons = toIdMap(
|
||||
await client.findAll(
|
||||
contact.class.Person,
|
||||
{
|
||||
_id: { $in: personRefs }
|
||||
},
|
||||
{
|
||||
lookup: {
|
||||
_id: { socialIds: contact.class.SocialIdentity }
|
||||
}
|
||||
}
|
||||
}
|
||||
))
|
||||
)
|
||||
)
|
||||
|
||||
for (const personRef of personRefs) {
|
||||
const person = persons.get(personRef)
|
||||
@ -616,15 +629,22 @@ export async function getPersonRefByPersonId (client: Client, personId: PersonId
|
||||
return contactCache.personRefByPersonId.get(personId) ?? null
|
||||
}
|
||||
|
||||
export async function getPersonRefsByPersonIds (client: Client, personIds: PersonId[]): Promise<Map<PersonId, Ref<Person>>> {
|
||||
export async function getPersonRefsByPersonIds (
|
||||
client: Client,
|
||||
personIds: PersonId[]
|
||||
): Promise<Map<PersonId, Ref<Person>>> {
|
||||
if (personIds.some((personId) => !contactCache.personRefByPersonId.has(personId))) {
|
||||
await loadCachesForPersonIds(client, personIds)
|
||||
}
|
||||
|
||||
return new Map(personIds.map((pid) => {
|
||||
const ref = contactCache.personRefByPersonId.get(pid)
|
||||
return ref != null ? [pid, ref] as const : undefined
|
||||
}).filter(notEmpty))
|
||||
return new Map(
|
||||
personIds
|
||||
.map((pid) => {
|
||||
const ref = contactCache.personRefByPersonId.get(pid)
|
||||
return ref != null ? ([pid, ref] as const) : undefined
|
||||
})
|
||||
.filter(notEmpty)
|
||||
)
|
||||
}
|
||||
|
||||
export async function getPersonByPersonId (client: Client, personId: PersonId): Promise<Readonly<Person> | null> {
|
||||
@ -635,15 +655,22 @@ export async function getPersonByPersonId (client: Client, personId: PersonId):
|
||||
return contactCache.personByPersonId.get(personId) ?? null
|
||||
}
|
||||
|
||||
export async function getPersonsByPersonIds (client: Client, personIds: PersonId[]): Promise<Map<PersonId, Readonly<Person>>> {
|
||||
export async function getPersonsByPersonIds (
|
||||
client: Client,
|
||||
personIds: PersonId[]
|
||||
): Promise<Map<PersonId, Readonly<Person>>> {
|
||||
if (personIds.some((personId) => !contactCache.personByPersonId.has(personId))) {
|
||||
await loadCachesForPersonIds(client, personIds)
|
||||
}
|
||||
|
||||
return new Map(personIds.map((pid) => {
|
||||
const person = contactCache.personByPersonId.get(pid)
|
||||
return person != null ? [pid, person] as const : undefined
|
||||
}).filter(notEmpty))
|
||||
return new Map(
|
||||
personIds
|
||||
.map((pid) => {
|
||||
const person = contactCache.personByPersonId.get(pid)
|
||||
return person != null ? ([pid, person] as const) : undefined
|
||||
})
|
||||
.filter(notEmpty)
|
||||
)
|
||||
}
|
||||
|
||||
export async function getPersonByPersonRef (client: Client, personRef: Ref<Person>): Promise<Readonly<Person> | null> {
|
||||
@ -654,15 +681,22 @@ export async function getPersonByPersonRef (client: Client, personRef: Ref<Perso
|
||||
return contactCache.personByRef.get(personRef) ?? null
|
||||
}
|
||||
|
||||
export async function getPersonsByPersonRefs (client: Client, personRefs: Array<Ref<Person>>): Promise<Map<Ref<Person>, Readonly<Person>>> {
|
||||
export async function getPersonsByPersonRefs (
|
||||
client: Client,
|
||||
personRefs: Array<Ref<Person>>
|
||||
): Promise<Map<Ref<Person>, Readonly<Person>>> {
|
||||
if (personRefs.some((personRef) => !contactCache.personByRef.has(personRef))) {
|
||||
await loadCachesForPersonRefs(client, personRefs)
|
||||
}
|
||||
|
||||
return new Map(personRefs.map((personRef) => {
|
||||
const person = contactCache.personByRef.get(personRef)
|
||||
return person != null ? [personRef, person] as const : undefined
|
||||
}).filter(notEmpty))
|
||||
return new Map(
|
||||
personRefs
|
||||
.map((personRef) => {
|
||||
const person = contactCache.personByRef.get(personRef)
|
||||
return person != null ? ([personRef, person] as const) : undefined
|
||||
})
|
||||
.filter(notEmpty)
|
||||
)
|
||||
}
|
||||
|
||||
export async function getSocialIdByPersonId (client: Client, personId: PersonId): Promise<SocialIdentity | null> {
|
||||
|
@ -47,15 +47,12 @@
|
||||
}
|
||||
|
||||
let workflow: Map<Ref<ControlledDocument>, DocumentValidationState[]>
|
||||
$: void extractValidationWorkflow(
|
||||
hierarchy,
|
||||
{
|
||||
...emptyBundle(),
|
||||
ControlledDocument: doc ? [doc] : [],
|
||||
DocumentRequest: requests,
|
||||
DocumentSnapshot: $documentSnapshots
|
||||
}
|
||||
).then((res) => {
|
||||
$: void extractValidationWorkflow(hierarchy, {
|
||||
...emptyBundle(),
|
||||
ControlledDocument: doc ? [doc] : [],
|
||||
DocumentRequest: requests,
|
||||
DocumentSnapshot: $documentSnapshots
|
||||
}).then((res) => {
|
||||
workflow = res
|
||||
})
|
||||
|
||||
|
@ -46,16 +46,13 @@
|
||||
}
|
||||
|
||||
let workflow: Map<Ref<ControlledDocument>, DocumentValidationState[]>
|
||||
$: void extractValidationWorkflow(
|
||||
hierarchy,
|
||||
{
|
||||
...emptyBundle(),
|
||||
ControlledDocument: doc ? [doc] : [],
|
||||
DocumentRequest: requests,
|
||||
DocumentSnapshot: $documentSnapshots,
|
||||
ChatMessage: messages
|
||||
}
|
||||
).then((res) => {
|
||||
$: void extractValidationWorkflow(hierarchy, {
|
||||
...emptyBundle(),
|
||||
ControlledDocument: doc ? [doc] : [],
|
||||
DocumentRequest: requests,
|
||||
DocumentSnapshot: $documentSnapshots,
|
||||
ChatMessage: messages
|
||||
}).then((res) => {
|
||||
workflow = res
|
||||
})
|
||||
|
||||
|
@ -1123,7 +1123,9 @@ export async function extractValidationWorkflow (
|
||||
|
||||
const anchor = review ?? approval
|
||||
const author =
|
||||
anchor?.createdBy !== undefined ? await getPersonRefByPersonId(anchor.createdBy) ?? document.author : document.author
|
||||
anchor?.createdBy !== undefined
|
||||
? (await getPersonRefByPersonId(anchor.createdBy)) ?? document.author
|
||||
: document.author
|
||||
|
||||
state.approvals = [
|
||||
{
|
||||
@ -1132,8 +1134,8 @@ export async function extractValidationWorkflow (
|
||||
state: anchor !== undefined ? 'approved' : 'waiting',
|
||||
timestamp: anchor !== undefined ? anchor.createdOn ?? document.createdOn : undefined
|
||||
},
|
||||
...await getApprovalStates(review),
|
||||
...await getApprovalStates(approval)
|
||||
...(await getApprovalStates(review)),
|
||||
...(await getApprovalStates(approval))
|
||||
]
|
||||
|
||||
if (state.requests.length > 0) {
|
||||
|
@ -81,7 +81,7 @@
|
||||
object._class,
|
||||
'gmailSharedMessages',
|
||||
{
|
||||
messages: convertMessages(object, channel, selectedMessages)
|
||||
messages: await convertMessages(object, channel, selectedMessages)
|
||||
}
|
||||
)
|
||||
await inboxClient.readDoc(channel._id)
|
||||
@ -126,12 +126,14 @@
|
||||
</div>
|
||||
|
||||
{#if messages && messages.length > 0}
|
||||
<div class="antiVSpacer x2" />
|
||||
<Scroller padding={'.5rem 1rem'}>
|
||||
<Messages messages={convertMessages(object, channel, messages)} {selectable} bind:selected on:select />
|
||||
{#await convertMessages(object, channel, messages) then convertedMessages}
|
||||
<div class="antiVSpacer x2" />
|
||||
</Scroller>
|
||||
<div class="antiVSpacer x2" />
|
||||
<Scroller padding={'.5rem 1rem'}>
|
||||
<Messages messages={convertedMessages} {selectable} bind:selected on:select />
|
||||
<div class="antiVSpacer x2" />
|
||||
</Scroller>
|
||||
<div class="antiVSpacer x2" />
|
||||
{/await}
|
||||
{:else}
|
||||
<div class="flex-col-center justify-center h-full">
|
||||
<Icon icon={IconInbox} size={'full'} />
|
||||
|
@ -65,7 +65,11 @@ export async function checkHasEmail (doc: Doc | Doc[] | undefined): Promise<bool
|
||||
const EMAIL_REGEX =
|
||||
/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/
|
||||
|
||||
export async function convertMessages (object: Contact, channel: Channel, messages: Message[]): Promise<SharedMessage[]> {
|
||||
export async function convertMessages (
|
||||
object: Contact,
|
||||
channel: Channel,
|
||||
messages: Message[]
|
||||
): Promise<SharedMessage[]> {
|
||||
const res: SharedMessage[] = []
|
||||
for (const m of messages) {
|
||||
res.push({
|
||||
|
@ -37,7 +37,7 @@
|
||||
author = $employeeByPersonIdStore.get(socialId)
|
||||
|
||||
if (author === undefined) {
|
||||
author = await getPersonByPersonId(socialId) ?? undefined
|
||||
author = (await getPersonByPersonId(socialId)) ?? undefined
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -12,13 +12,13 @@
|
||||
<!-- limitations under the License. -->
|
||||
|
||||
<script lang="ts">
|
||||
import { getClient, LiteMessageViewer } from '@hcengineering/presentation'
|
||||
import { LiteMessageViewer } from '@hcengineering/presentation'
|
||||
import { Card } from '@hcengineering/card'
|
||||
import { type WithLookup } from '@hcengineering/core'
|
||||
import { Message, MessageType, SocialID } from '@hcengineering/communication-types'
|
||||
import { getPersonBySocialId, Person } from '@hcengineering/contact'
|
||||
import { Person } from '@hcengineering/contact'
|
||||
import { getEmbeddedLabel, IntlString } from '@hcengineering/platform'
|
||||
import { personByPersonIdStore } from '@hcengineering/contact-resources'
|
||||
import { employeeByPersonIdStore, getPersonByPersonId } from '@hcengineering/contact-resources'
|
||||
import { markdownToMarkup } from '@hcengineering/text-markdown'
|
||||
import { jsonToMarkup, markupToText } from '@hcengineering/text'
|
||||
import { ActivityMessageViewer, ThreadMessageViewer, isActivityMessage } from '@hcengineering/communication-resources'
|
||||
@ -33,8 +33,6 @@
|
||||
export let kind: 'default' | 'column' = 'default'
|
||||
export let padding: string | undefined = undefined
|
||||
|
||||
const client = getClient()
|
||||
|
||||
const tooltipLimit = 512
|
||||
|
||||
let person: WithLookup<Person> | undefined = undefined
|
||||
@ -50,7 +48,7 @@
|
||||
}
|
||||
|
||||
async function updatePerson (socialId: SocialID): Promise<void> {
|
||||
person = $personByPersonIdStore.get(socialId) ?? (await getPersonBySocialId(client, socialId))
|
||||
person = $employeeByPersonIdStore.get(socialId) ?? (await getPersonByPersonId(socialId)) ?? undefined
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -12,12 +12,11 @@
|
||||
<!-- limitations under the License. -->
|
||||
|
||||
<script lang="ts">
|
||||
import { Person, formatName, getPersonBySocialId } from '@hcengineering/contact'
|
||||
import { Person, formatName } from '@hcengineering/contact'
|
||||
import { IntlString } from '@hcengineering/platform'
|
||||
import { resizeObserver, TimeSince, tooltip } from '@hcengineering/ui'
|
||||
import { Avatar, PersonPreviewProvider, SystemAvatar, personByPersonIdStore } from '@hcengineering/contact-resources'
|
||||
import { Avatar, PersonPreviewProvider, SystemAvatar, employeeByPersonIdStore, getPersonByPersonId } from '@hcengineering/contact-resources'
|
||||
import { SocialID } from '@hcengineering/communication-types'
|
||||
import { getClient } from '@hcengineering/presentation'
|
||||
|
||||
export let tooltipLabel: IntlString | undefined = undefined
|
||||
export let person: Person | undefined = undefined
|
||||
@ -28,7 +27,6 @@
|
||||
export let padding: string | undefined = undefined
|
||||
export let fixHeight: boolean = false
|
||||
|
||||
const client = getClient()
|
||||
let clientWidth: number
|
||||
|
||||
$: showPersonName = clientWidth > 300
|
||||
@ -37,9 +35,9 @@
|
||||
$: void updatePerson(socialId, person)
|
||||
|
||||
async function updatePerson (socialId: SocialID, person: Person | undefined): Promise<void> {
|
||||
_person = person ?? $personByPersonIdStore.get(socialId)
|
||||
_person = person ?? $employeeByPersonIdStore.get(socialId)
|
||||
if (!_person) {
|
||||
_person = await getPersonBySocialId(client, socialId)
|
||||
_person = await getPersonByPersonId(socialId) ?? undefined
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -221,12 +221,7 @@
|
||||
{/each}
|
||||
{/each}
|
||||
<div class="floorGrid-configureRoom__header">
|
||||
<EditBox
|
||||
bind:value={room.name}
|
||||
on:change={updateName}
|
||||
placeholder={roomLabel}
|
||||
kind={'editbox'}
|
||||
/>
|
||||
<EditBox bind:value={room.name} on:change={updateName} placeholder={roomLabel} kind={'editbox'} />
|
||||
{#if showButtons}
|
||||
<div
|
||||
class="flex-row-center flex-no-shrink h-full {zoomOut ? 'flex-gap-1' : 'flex-gap-2'}"
|
||||
|
@ -52,7 +52,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
return await getPersonByPersonRef(info.person) ?? undefined
|
||||
return (await getPersonByPersonRef(info.person)) ?? undefined
|
||||
}
|
||||
|
||||
function getPersonInfo (y: number, x: number, info: ParticipantInfo[]): ParticipantInfo | undefined {
|
||||
|
@ -42,7 +42,12 @@
|
||||
})
|
||||
.map((room) => makeRoomItem(room, false))
|
||||
|
||||
$: personByRefStore = getPersonByPersonRefStore($rooms.filter(isOffice).map((r) => r.person).filter(notEmpty))
|
||||
$: personByRefStore = getPersonByPersonRefStore(
|
||||
$rooms
|
||||
.filter(isOffice)
|
||||
.map((r) => r.person)
|
||||
.filter(notEmpty)
|
||||
)
|
||||
$: selectedRoom = $rooms.find((p) => p._id === value)
|
||||
$: selected = selectedRoom !== undefined ? makeRoomItem(selectedRoom, true) : undefined
|
||||
|
||||
|
@ -14,7 +14,6 @@ import core, {
|
||||
generateId,
|
||||
getCurrentAccount,
|
||||
type Hierarchy,
|
||||
type IdMap,
|
||||
type Ref,
|
||||
type RelatedDocument,
|
||||
type Space,
|
||||
|
@ -107,7 +107,7 @@
|
||||
const result: Array<InboxNotification[]> = []
|
||||
let group: InboxNotification[] = []
|
||||
let person: Ref<Person> | undefined = undefined
|
||||
const personRefByPersonId = await getPersonRefsByPersonIds(notifications.map(it => it.createdBy ?? it.modifiedBy))
|
||||
const personRefByPersonId = await getPersonRefsByPersonIds(notifications.map((it) => it.createdBy ?? it.modifiedBy))
|
||||
|
||||
for (const it of notifications) {
|
||||
const pid = it.createdBy ?? it.modifiedBy
|
||||
|
@ -163,7 +163,7 @@ export async function getFollowee (): Promise<Person | undefined> {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return await getPersonByPersonRef(followeeId) ?? undefined
|
||||
return (await getPersonByPersonRef(followeeId)) ?? undefined
|
||||
}
|
||||
|
||||
export function publishData (topic: string, data: any): void {
|
||||
|
@ -32,8 +32,8 @@ export const presencePlugin = plugin(presenceId, {
|
||||
function: {
|
||||
PublishData: '' as Resource<(topic: string, data: any) => void>,
|
||||
GetFollowee: '' as Resource<() => Person | undefined>,
|
||||
FolloweeDataSubscribe: '' as Resource<(topic: string, handler: (data: any) => void) => void>,
|
||||
FolloweeDataUnsubscribe: '' as Resource<(topic: string, handler: (data: any) => void) => void>
|
||||
FolloweeDataSubscribe: '' as Resource<(topic: string, handler: (data: any) => Promise<void>) => void>,
|
||||
FolloweeDataUnsubscribe: '' as Resource<(topic: string, handler: (data: any) => Promise<void>) => void>
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -29,11 +29,13 @@
|
||||
$: query.query(request.mixin.RequestDecisionComment, { attachedTo: value._id }, (res) => {
|
||||
comments = res
|
||||
})
|
||||
$: void getPersonRefsByPersonIds(comments.map(it => it.modifiedBy)).then((res) => {
|
||||
commentsByPersonRefs = new Map(comments.map((c) => {
|
||||
const personRef = res.get(c.modifiedBy)
|
||||
return [personRef, c]
|
||||
}))
|
||||
$: void getPersonRefsByPersonIds(comments.map((it) => it.modifiedBy)).then((res) => {
|
||||
commentsByPersonRefs = new Map(
|
||||
comments.map((c) => {
|
||||
const personRef = res.get(c.modifiedBy)
|
||||
return [personRef, c]
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
interface RequestDecision {
|
||||
|
@ -16,10 +16,7 @@
|
||||
import calendar, { Event, getAllEvents } from '@hcengineering/calendar'
|
||||
import { calendarByIdStore } from '@hcengineering/calendar-resources'
|
||||
import contact, { getCurrentEmployee, Person } from '@hcengineering/contact'
|
||||
import {
|
||||
employeeRefByAccountUuidStore,
|
||||
getPersonRefsByPersonIds
|
||||
} from '@hcengineering/contact-resources'
|
||||
import { employeeRefByAccountUuidStore, getPersonRefsByPersonIds } from '@hcengineering/contact-resources'
|
||||
import core, { Doc, IdMap, PersonId, Ref, Timestamp, Tx, TxCreateDoc, TxCUD, TxUpdateDoc } from '@hcengineering/core'
|
||||
import { Asset } from '@hcengineering/platform'
|
||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||
@ -59,13 +56,9 @@
|
||||
|
||||
const socialIdsQuery = createQuery()
|
||||
$: if (personsRefs.length > 0) {
|
||||
socialIdsQuery.query(
|
||||
contact.class.SocialIdentity,
|
||||
{ attachedTo: { $in: personsRefs } },
|
||||
(res) => {
|
||||
personsSocialIds = res.map((si) => si._id).flat()
|
||||
}
|
||||
)
|
||||
socialIdsQuery.query(contact.class.SocialIdentity, { attachedTo: { $in: personsRefs } }, (res) => {
|
||||
personsSocialIds = res.map((si) => si._id).flat()
|
||||
})
|
||||
} else {
|
||||
socialIdsQuery.unsubscribe()
|
||||
}
|
||||
@ -77,7 +70,7 @@
|
||||
txes = res
|
||||
}
|
||||
)
|
||||
$: void getPersonRefsByPersonIds(Array.from(new Set(txes.map(it => it.createdBy ?? it.modifiedBy)))).then((res) => {
|
||||
$: void getPersonRefsByPersonIds(Array.from(new Set(txes.map((it) => it.createdBy ?? it.modifiedBy)))).then((res) => {
|
||||
const map = new Map<Ref<Person>, Tx[]>()
|
||||
for (const t of txes) {
|
||||
const personId = t.createdBy ?? t.modifiedBy
|
||||
|
@ -15,11 +15,7 @@
|
||||
<script lang="ts">
|
||||
import { Analytics } from '@hcengineering/analytics'
|
||||
import { Employee } from '@hcengineering/contact'
|
||||
import {
|
||||
AccountArrayEditor,
|
||||
AssigneeBox,
|
||||
employeeRefByAccountUuidStore
|
||||
} from '@hcengineering/contact-resources'
|
||||
import { AccountArrayEditor, AssigneeBox, employeeRefByAccountUuidStore } from '@hcengineering/contact-resources'
|
||||
import core, {
|
||||
Data,
|
||||
DocumentUpdate,
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
async function getPerson (id: PersonId | undefined): Promise<void> {
|
||||
if (id !== undefined) {
|
||||
person = await getPersonRefByPersonId(client, id)
|
||||
person = await getPersonRefByPersonId(client, id) ?? undefined
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user