mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-24 01:07:50 +00:00
Fix multiple channels (#3474)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
b3a9498b71
commit
6100c73ae4
plugins
contact-resources/src/components
gmail-resources/src/components
telegram-resources/src/components
@ -77,7 +77,7 @@
|
|||||||
if (ev.detail.presenter !== undefined) {
|
if (ev.detail.presenter !== undefined) {
|
||||||
if (allowOpen) {
|
if (allowOpen) {
|
||||||
closeTooltip()
|
closeTooltip()
|
||||||
showPopup(ev.detail.presenter, { _id: attachedTo, _class: attachedClass }, 'float')
|
showPopup(ev.detail.presenter, { channel: ev.detail.channel }, 'float')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,7 @@
|
|||||||
|
|
||||||
async function _open (ev: CustomEvent): Promise<void> {
|
async function _open (ev: CustomEvent): Promise<void> {
|
||||||
if (ev.detail.presenter !== undefined && Array.isArray(value)) {
|
if (ev.detail.presenter !== undefined && Array.isArray(value)) {
|
||||||
showPopup(
|
showPopup(ev.detail.presenter, { channel: ev.detail.channel }, 'float')
|
||||||
ev.detail.presenter,
|
|
||||||
{ _id: ev.detail.channel.attachedTo, _class: ev.detail.channel.attachedToClass },
|
|
||||||
'float'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
if (ev.detail.action !== undefined && Array.isArray(value)) {
|
if (ev.detail.action !== undefined && Array.isArray(value)) {
|
||||||
const action = await getResource(ev.detail.action as ViewAction)
|
const action = await getResource(ev.detail.action as ViewAction)
|
||||||
|
@ -15,26 +15,25 @@
|
|||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import contact, { Channel, Contact, getName } from '@hcengineering/contact'
|
import contact, { Channel, Contact, getName } from '@hcengineering/contact'
|
||||||
import { Class, getCurrentAccount, Ref } from '@hcengineering/core'
|
import { employeeByIdStore } from '@hcengineering/contact-resources'
|
||||||
|
import { getCurrentAccount } from '@hcengineering/core'
|
||||||
import { Message, SharedMessage } from '@hcengineering/gmail'
|
import { Message, SharedMessage } from '@hcengineering/gmail'
|
||||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||||
import { getResource } from '@hcengineering/platform'
|
import { getResource } from '@hcengineering/platform'
|
||||||
import { createQuery } from '@hcengineering/presentation'
|
import { createQuery } from '@hcengineering/presentation'
|
||||||
import setting, { Integration } from '@hcengineering/setting'
|
import setting, { Integration } from '@hcengineering/setting'
|
||||||
import templates, { TemplateDataProvider } from '@hcengineering/templates'
|
import templates, { TemplateDataProvider } from '@hcengineering/templates'
|
||||||
import { Button, eventToHTMLElement, Icon, Label, Panel, showPopup } from '@hcengineering/ui'
|
import { Button, Icon, Label, Panel, eventToHTMLElement, showPopup } from '@hcengineering/ui'
|
||||||
import { createEventDispatcher, onDestroy } from 'svelte'
|
import { createEventDispatcher, onDestroy } from 'svelte'
|
||||||
import gmail from '../plugin'
|
import gmail from '../plugin'
|
||||||
|
import { convertMessage } from '../utils'
|
||||||
import Chats from './Chats.svelte'
|
import Chats from './Chats.svelte'
|
||||||
import Connect from './Connect.svelte'
|
import Connect from './Connect.svelte'
|
||||||
import FullMessage from './FullMessage.svelte'
|
import FullMessage from './FullMessage.svelte'
|
||||||
import IntegrationSelector from './IntegrationSelector.svelte'
|
import IntegrationSelector from './IntegrationSelector.svelte'
|
||||||
import NewMessage from './NewMessage.svelte'
|
import NewMessage from './NewMessage.svelte'
|
||||||
import { convertMessage } from '../utils'
|
|
||||||
import { employeeByIdStore } from '@hcengineering/contact-resources'
|
|
||||||
|
|
||||||
export let _id: Ref<Contact>
|
export let channel: Channel
|
||||||
export let _class: Ref<Class<Contact>>
|
|
||||||
export let embedded = false
|
export let embedded = false
|
||||||
export let message: Message | undefined = undefined
|
export let message: Message | undefined = undefined
|
||||||
|
|
||||||
@ -42,34 +41,18 @@
|
|||||||
let currentMessage: SharedMessage | undefined = undefined
|
let currentMessage: SharedMessage | undefined = undefined
|
||||||
|
|
||||||
let newMessage: boolean = false
|
let newMessage: boolean = false
|
||||||
let channel: Channel | undefined = undefined
|
|
||||||
const notificationClient = NotificationClientImpl.getClient()
|
const notificationClient = NotificationClientImpl.getClient()
|
||||||
let integrations: Integration[] = []
|
let integrations: Integration[] = []
|
||||||
let selectedIntegration: Integration | undefined = undefined
|
let selectedIntegration: Integration | undefined = undefined
|
||||||
|
|
||||||
const channelQuery = createQuery()
|
notificationClient.forceRead(channel._id, channel._class)
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
$: channelQuery.query(
|
|
||||||
contact.class.Channel,
|
|
||||||
{
|
|
||||||
attachedTo: _id,
|
|
||||||
provider: contact.channelProvider.Email
|
|
||||||
},
|
|
||||||
(res) => {
|
|
||||||
channel = res[0]
|
|
||||||
if (channel !== undefined) {
|
|
||||||
notificationClient.forceRead(channel._id, channel._class)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const query = createQuery()
|
const query = createQuery()
|
||||||
$: _id &&
|
$: query.query(channel.attachedToClass, { _id: channel.attachedTo }, (result) => {
|
||||||
_class &&
|
object = result[0] as Contact
|
||||||
query.query(_class, { _id }, (result) => {
|
})
|
||||||
object = result[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
function back () {
|
function back () {
|
||||||
if (newMessage) {
|
if (newMessage) {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
getName as getContactName
|
getName as getContactName
|
||||||
} from '@hcengineering/contact'
|
} from '@hcengineering/contact'
|
||||||
import { Avatar, employeeAccountByIdStore, employeeByIdStore } from '@hcengineering/contact-resources'
|
import { Avatar, employeeAccountByIdStore, employeeByIdStore } from '@hcengineering/contact-resources'
|
||||||
import { Class, IdMap, Ref, SortingOrder, generateId, getCurrentAccount } from '@hcengineering/core'
|
import { IdMap, Ref, SortingOrder, generateId, getCurrentAccount } from '@hcengineering/core'
|
||||||
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
import { NotificationClientImpl } from '@hcengineering/notification-resources'
|
||||||
import { getEmbeddedLabel, getResource } from '@hcengineering/platform'
|
import { getEmbeddedLabel, getResource } from '@hcengineering/platform'
|
||||||
import { createQuery, getClient } from '@hcengineering/presentation'
|
import { createQuery, getClient } from '@hcengineering/presentation'
|
||||||
@ -49,30 +49,16 @@
|
|||||||
import Reconnect from './Reconnect.svelte'
|
import Reconnect from './Reconnect.svelte'
|
||||||
import TelegramIcon from './icons/Telegram.svelte'
|
import TelegramIcon from './icons/Telegram.svelte'
|
||||||
|
|
||||||
export let _id: Ref<Contact>
|
export let channel: Channel
|
||||||
export let _class: Ref<Class<Contact>>
|
|
||||||
export let embedded = false
|
export let embedded = false
|
||||||
|
|
||||||
let object: Contact
|
let object: Contact
|
||||||
let channel: Channel | undefined = undefined
|
|
||||||
let objectId: Ref<NewTelegramMessage> = generateId()
|
let objectId: Ref<NewTelegramMessage> = generateId()
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
const notificationClient = NotificationClientImpl.getClient()
|
const notificationClient = NotificationClientImpl.getClient()
|
||||||
const channelQuery = createQuery()
|
|
||||||
|
|
||||||
$: channelQuery.query(
|
|
||||||
contact.class.Channel,
|
|
||||||
{
|
|
||||||
attachedTo: _id,
|
|
||||||
provider: contact.channelProvider.Telegram
|
|
||||||
},
|
|
||||||
(res) => {
|
|
||||||
channel = res[0]
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
let templateProvider: TemplateDataProvider | undefined
|
let templateProvider: TemplateDataProvider | undefined
|
||||||
|
|
||||||
@ -88,11 +74,9 @@
|
|||||||
$: templateProvider && integration && templateProvider.set(setting.class.Integration, integration)
|
$: templateProvider && integration && templateProvider.set(setting.class.Integration, integration)
|
||||||
|
|
||||||
const query = createQuery()
|
const query = createQuery()
|
||||||
$: _id &&
|
$: query.query(channel.attachedToClass, { _id: channel.attachedTo }, (result) => {
|
||||||
_class &&
|
object = result[0] as Contact
|
||||||
query.query(_class, { _id }, (result) => {
|
})
|
||||||
object = result[0]
|
|
||||||
})
|
|
||||||
|
|
||||||
let messages: TelegramMessage[] = []
|
let messages: TelegramMessage[] = []
|
||||||
let integration: Integration | undefined
|
let integration: Integration | undefined
|
||||||
|
Loading…
Reference in New Issue
Block a user