Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/chunter-resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@anticrm/chunter": "~0.6.1",
"@anticrm/login": "~0.6.1",
"svelte": "^3.47",
"fast-equals": "^2.0.3",
"@anticrm/text-editor": "~0.6.0",
"@anticrm/contact": "~0.6.5",
"@anticrm/contact-resources": "~0.6.0",
Expand Down
13 changes: 10 additions & 3 deletions plugins/chunter-resources/src/components/CreateChannel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import { IconFolder, EditBox, ToggleWithLabel, Grid } from '@anticrm/ui'

import workbench from '@anticrm/workbench'
import { getClient, SpaceCreateCard } from '@anticrm/presentation'
import { getResource } from '@anticrm/platform'

import chunter from '../plugin'
import core, { getCurrentAccount } from '@anticrm/core'
Expand All @@ -30,14 +31,20 @@
}
const client = getClient()

function createChannel () {
client.createDoc(chunter.class.Channel, core.space.Space, {
async function createChannel () {
const channelId = await client.createDoc(chunter.class.Channel, core.space.Space, {
name,
description: '',
private: isPrivate,
archived: false,
members: [getCurrentAccount()._id]
})
const navigate = await getResource(workbench.actionImpl.Navigate)

await navigate([], undefined as any, {
mode: 'space',
space: channelId
})
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
-->
<script lang="ts">
import { createEventDispatcher } from 'svelte'
import { deepEqual } from 'fast-equals'

import contact, { Employee } from '@anticrm/contact'
import core, { getCurrentAccount, Ref } from '@anticrm/core'
import { getClient, SpaceCreateCard, UserBoxList } from '@anticrm/presentation'
import workbench from '@anticrm/workbench'
import { getResource } from '@anticrm/platform'

import chunter from '../plugin'

Expand All @@ -27,15 +30,35 @@

let employeeIds: Ref<Employee>[] = []

function createDirectMessage () {
client.findAll(contact.class.EmployeeAccount, { employee: { $in: employeeIds } }).then((employeeAccounts) => {
client.createDoc(chunter.class.DirectMessage, core.space.Space, {
name: '',
description: '',
private: true,
archived: false,
members: [myAccId, ...employeeAccounts.filter((ea) => ea._id !== myAccId).map((ea) => ea._id)]
})
async function createDirectMessage () {
const employeeAccounts = await client.findAll(contact.class.EmployeeAccount, { employee: { $in: employeeIds } })

const accIds = [myAccId, ...employeeAccounts.filter((ea) => ea._id !== myAccId).map((ea) => ea._id)].sort()
const existingDms = await client.findAll(chunter.class.DirectMessage, {})
const navigate = await getResource(workbench.actionImpl.Navigate)

for (const dm of existingDms) {
if (deepEqual(dm.members.sort(), accIds)) {
await navigate([], undefined as any, {
mode: 'space',
space: dm._id
})

return
}
}

const dmId = await client.createDoc(chunter.class.DirectMessage, core.space.Space, {
name: '',
description: '',
private: true,
archived: false,
members: accIds
})

await navigate([], undefined as any, {
mode: 'space',
space: dmId
})
}
</script>
Expand Down