mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 07:46:24 +00:00
Telegram message date fix (#1614)
Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
parent
24ece32305
commit
a44fb47592
@ -15,9 +15,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import activity from '@anticrm/activity'
|
import activity from '@anticrm/activity'
|
||||||
import { Domain, IndexKind, Type } from '@anticrm/core'
|
import { Domain, IndexKind, Timestamp, Type } from '@anticrm/core'
|
||||||
import type { Message, NewMessage, SharedMessage, SharedMessages } from '@anticrm/gmail'
|
import type { Message, NewMessage, SharedMessage, SharedMessages } from '@anticrm/gmail'
|
||||||
import { ArrOf, Builder, Collection, Index, Model, Prop, TypeBoolean, TypeString } from '@anticrm/model'
|
import { ArrOf, Builder, Collection, Index, Model, Prop, TypeBoolean, TypeString, TypeTimestamp } from '@anticrm/model'
|
||||||
import contact from '@anticrm/model-contact'
|
import contact from '@anticrm/model-contact'
|
||||||
import core, { TDoc, TAttachedDoc } from '@anticrm/model-core'
|
import core, { TDoc, TAttachedDoc } from '@anticrm/model-core'
|
||||||
import attachment from '@anticrm/model-attachment'
|
import attachment from '@anticrm/model-attachment'
|
||||||
@ -67,6 +67,9 @@ export class TMessage extends TAttachedDoc implements Message {
|
|||||||
|
|
||||||
@Prop(Collection(attachment.class.Attachment), attachment.string.Attachments)
|
@Prop(Collection(attachment.class.Attachment), attachment.string.Attachments)
|
||||||
attachments?: number
|
attachments?: number
|
||||||
|
|
||||||
|
@Prop(TypeTimestamp(), core.string.Modified)
|
||||||
|
sendOn!: Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(gmail.class.NewMessage, core.class.Doc, DOMAIN_GMAIL)
|
@Model(gmail.class.NewMessage, core.class.Doc, DOMAIN_GMAIL)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import { Builder, Model, TypeString, TypeBoolean, Prop, ArrOf, Index, Collection } from '@anticrm/model'
|
import { Builder, Model, TypeString, TypeBoolean, Prop, ArrOf, Index, Collection, TypeTimestamp } from '@anticrm/model'
|
||||||
import core, { TAttachedDoc } from '@anticrm/model-core'
|
import core, { TAttachedDoc } from '@anticrm/model-core'
|
||||||
import contact from '@anticrm/model-contact'
|
import contact from '@anticrm/model-contact'
|
||||||
import telegram from './plugin'
|
import telegram from './plugin'
|
||||||
@ -24,7 +24,7 @@ import type {
|
|||||||
SharedTelegramMessage,
|
SharedTelegramMessage,
|
||||||
SharedTelegramMessages
|
SharedTelegramMessages
|
||||||
} from '@anticrm/telegram'
|
} from '@anticrm/telegram'
|
||||||
import { Domain, IndexKind, Type } from '@anticrm/core'
|
import { Domain, IndexKind, Timestamp, Type } from '@anticrm/core'
|
||||||
import setting from '@anticrm/setting'
|
import setting from '@anticrm/setting'
|
||||||
import activity from '@anticrm/activity'
|
import activity from '@anticrm/activity'
|
||||||
import attachment from '@anticrm/model-attachment'
|
import attachment from '@anticrm/model-attachment'
|
||||||
@ -46,6 +46,9 @@ export class TTelegramMessage extends TAttachedDoc implements TelegramMessage {
|
|||||||
|
|
||||||
@Prop(Collection(attachment.class.Attachment), attachment.string.Attachments)
|
@Prop(Collection(attachment.class.Attachment), attachment.string.Attachments)
|
||||||
attachments?: number
|
attachments?: number
|
||||||
|
|
||||||
|
@Prop(TypeTimestamp(), core.string.Modified)
|
||||||
|
sendOn!: Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Model(telegram.class.NewMessage, core.class.AttachedDoc, DOMAIN_TELEGRAM)
|
@Model(telegram.class.NewMessage, core.class.AttachedDoc, DOMAIN_TELEGRAM)
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
const accountsIds = new Set(messages.map((p) => p.modifiedBy as Ref<EmployeeAccount>))
|
const accountsIds = new Set(messages.map((p) => p.modifiedBy as Ref<EmployeeAccount>))
|
||||||
updateAccountsQuery(accountsIds)
|
updateAccountsQuery(accountsIds)
|
||||||
},
|
},
|
||||||
{ sort: { modifiedOn: SortingOrder.Descending } }
|
{ sort: { sendOn: SortingOrder.Descending } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="content-trans-color flex">
|
<div class="content-trans-color flex">
|
||||||
<AttachmentsPresenter value={message} />
|
<AttachmentsPresenter value={message} />
|
||||||
{getTime(message.modifiedOn)}
|
{getTime(message.sendOn)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-trans-color text-sm overflow-label mr-4 mb-4">
|
<div class="content-trans-color text-sm overflow-label mr-4 mb-4">
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import { plugin } from '@anticrm/platform'
|
import { plugin } from '@anticrm/platform'
|
||||||
import type { Plugin } from '@anticrm/platform'
|
import type { Plugin } from '@anticrm/platform'
|
||||||
import type { Doc, Ref, Class, Space, AttachedDoc } from '@anticrm/core'
|
import type { Doc, Ref, Class, Space, AttachedDoc, Timestamp } from '@anticrm/core'
|
||||||
import type { AnyComponent } from '@anticrm/ui'
|
import type { AnyComponent } from '@anticrm/ui'
|
||||||
import type { IntegrationType, Handler } from '@anticrm/setting'
|
import type { IntegrationType, Handler } from '@anticrm/setting'
|
||||||
|
|
||||||
@ -27,6 +27,7 @@ export interface Message extends BaseMessage, AttachedDoc {
|
|||||||
from: string
|
from: string
|
||||||
textContent: string
|
textContent: string
|
||||||
incoming: boolean
|
incoming: boolean
|
||||||
|
sendOn: Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,6 +62,7 @@ export interface SharedMessage extends Doc {
|
|||||||
textContent: string
|
textContent: string
|
||||||
attachments?: number
|
attachments?: number
|
||||||
copy?: string[]
|
copy?: string[]
|
||||||
|
sendOn: Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
import { AttachmentRefInput } from '@anticrm/attachment-resources'
|
import { AttachmentRefInput } from '@anticrm/attachment-resources'
|
||||||
import { Panel } from '@anticrm/panel'
|
import { Panel } from '@anticrm/panel'
|
||||||
import { createEventDispatcher } from 'svelte'
|
import { createEventDispatcher } from 'svelte'
|
||||||
import contact, { Channel, EmployeeAccount, formatName } from '@anticrm/contact'
|
import contact, { Channel, Contact, EmployeeAccount, formatName } from '@anticrm/contact'
|
||||||
import { generateId, getCurrentAccount, Ref, SortingOrder, Space, Doc, Class } from '@anticrm/core'
|
import { generateId, getCurrentAccount, Ref, SortingOrder, Space, Class } from '@anticrm/core'
|
||||||
import { NotificationClientImpl } from '@anticrm/notification-resources'
|
import { NotificationClientImpl } from '@anticrm/notification-resources'
|
||||||
import { createQuery, getClient } from '@anticrm/presentation'
|
import { createQuery, getClient } from '@anticrm/presentation'
|
||||||
import setting, { Integration } from '@anticrm/setting'
|
import setting, { Integration } from '@anticrm/setting'
|
||||||
@ -32,11 +32,11 @@
|
|||||||
import Messages from './Messages.svelte'
|
import Messages from './Messages.svelte'
|
||||||
import Reconnect from './Reconnect.svelte'
|
import Reconnect from './Reconnect.svelte'
|
||||||
|
|
||||||
export let _id: Ref<Doc>
|
export let _id: Ref<Contact>
|
||||||
export let _class: Ref<Class<Doc>>
|
export let _class: Ref<Class<Contact>>
|
||||||
export let rightSection: AnyComponent | undefined = undefined
|
export let rightSection: AnyComponent | undefined = undefined
|
||||||
|
|
||||||
let object: any
|
let object: Contact
|
||||||
let channel: Channel | undefined = undefined
|
let channel: Channel | undefined = undefined
|
||||||
let objectId: Ref<NewTelegramMessage> = generateId()
|
let objectId: Ref<NewTelegramMessage> = generateId()
|
||||||
|
|
||||||
@ -85,7 +85,7 @@
|
|||||||
updateAccountsQuery(accountsIds)
|
updateAccountsQuery(accountsIds)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sort: { modifiedOn: SortingOrder.Descending },
|
sort: { sendOn: SortingOrder.Descending },
|
||||||
limit: 500,
|
limit: 500,
|
||||||
lookup: {
|
lookup: {
|
||||||
_id: { attachments: attachment.class.Attachment }
|
_id: { attachments: attachment.class.Attachment }
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
export let message: SharedTelegramMessage
|
export let message: SharedTelegramMessage
|
||||||
|
|
||||||
const current = new Date()
|
const current = new Date()
|
||||||
const target = new Date(message.modifiedOn)
|
const target = new Date(message.sendOn)
|
||||||
let options: Intl.DateTimeFormatOptions = {
|
let options: Intl.DateTimeFormatOptions = {
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
month: 'long'
|
month: 'long'
|
||||||
@ -32,7 +32,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="datetime-container">
|
<div class="datetime-container">
|
||||||
{new Intl.DateTimeFormat('default', options).format(message.modifiedOn)}
|
{new Intl.DateTimeFormat('default', options).format(message.sendOn)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
<div class="flex">
|
<div class="flex">
|
||||||
<div class="caption-color mr-4"><MessageViewer message={message.content} /></div>
|
<div class="caption-color mr-4"><MessageViewer message={message.content} /></div>
|
||||||
<div class="time">
|
<div class="time">
|
||||||
{new Date(message.modifiedOn).toLocaleString('default', { hour: 'numeric', minute: 'numeric' })}
|
{new Date(message.sendOn).toLocaleString('default', { hour: 'numeric', minute: 'numeric' })}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
|
|
||||||
function isNewDate (messages: SharedTelegramMessage[], i: number): boolean {
|
function isNewDate (messages: SharedTelegramMessage[], i: number): boolean {
|
||||||
if (i === 0) return true
|
if (i === 0) return true
|
||||||
const current = new Date(messages[i].modifiedOn).toLocaleDateString()
|
const current = new Date(messages[i].sendOn).toLocaleDateString()
|
||||||
const prev = new Date(messages[i - 1].modifiedOn).toLocaleDateString()
|
const prev = new Date(messages[i - 1].sendOn).toLocaleDateString()
|
||||||
return current !== prev
|
return current !== prev
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import { plugin } from '@anticrm/platform'
|
import { plugin } from '@anticrm/platform'
|
||||||
import type { Plugin } from '@anticrm/platform'
|
import type { Plugin } from '@anticrm/platform'
|
||||||
import type { Doc, Ref, Class, Space, AttachedDoc } from '@anticrm/core'
|
import type { Doc, Ref, Class, Space, AttachedDoc, Timestamp } from '@anticrm/core'
|
||||||
import type { AnyComponent } from '@anticrm/ui'
|
import type { AnyComponent } from '@anticrm/ui'
|
||||||
import type { IntegrationType, Handler } from '@anticrm/setting'
|
import type { IntegrationType, Handler } from '@anticrm/setting'
|
||||||
|
|
||||||
@ -32,6 +32,8 @@ export interface BaseTelegramMessage extends Doc {
|
|||||||
*/
|
*/
|
||||||
export interface TelegramMessage extends BaseTelegramMessage, AttachedDoc {
|
export interface TelegramMessage extends BaseTelegramMessage, AttachedDoc {
|
||||||
incoming: boolean
|
incoming: boolean
|
||||||
|
|
||||||
|
sendOn: Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,6 +49,7 @@ export interface NewTelegramMessage extends BaseTelegramMessage, AttachedDoc {
|
|||||||
export interface SharedTelegramMessage extends BaseTelegramMessage {
|
export interface SharedTelegramMessage extends BaseTelegramMessage {
|
||||||
incoming: boolean
|
incoming: boolean
|
||||||
sender: string
|
sender: string
|
||||||
|
sendOn: Timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user