mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-22 08:20:39 +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 { Domain, IndexKind, Type } from '@anticrm/core'
|
||||
import { Domain, IndexKind, Timestamp, Type } from '@anticrm/core'
|
||||
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 core, { TDoc, TAttachedDoc } from '@anticrm/model-core'
|
||||
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)
|
||||
attachments?: number
|
||||
|
||||
@Prop(TypeTimestamp(), core.string.Modified)
|
||||
sendOn!: Timestamp
|
||||
}
|
||||
|
||||
@Model(gmail.class.NewMessage, core.class.Doc, DOMAIN_GMAIL)
|
||||
|
@ -14,7 +14,7 @@
|
||||
// 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 contact from '@anticrm/model-contact'
|
||||
import telegram from './plugin'
|
||||
@ -24,7 +24,7 @@ import type {
|
||||
SharedTelegramMessage,
|
||||
SharedTelegramMessages
|
||||
} from '@anticrm/telegram'
|
||||
import { Domain, IndexKind, Type } from '@anticrm/core'
|
||||
import { Domain, IndexKind, Timestamp, Type } from '@anticrm/core'
|
||||
import setting from '@anticrm/setting'
|
||||
import activity from '@anticrm/activity'
|
||||
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)
|
||||
attachments?: number
|
||||
|
||||
@Prop(TypeTimestamp(), core.string.Modified)
|
||||
sendOn!: Timestamp
|
||||
}
|
||||
|
||||
@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>))
|
||||
updateAccountsQuery(accountsIds)
|
||||
},
|
||||
{ sort: { modifiedOn: SortingOrder.Descending } }
|
||||
{ sort: { sendOn: SortingOrder.Descending } }
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
</div>
|
||||
<div class="content-trans-color flex">
|
||||
<AttachmentsPresenter value={message} />
|
||||
{getTime(message.modifiedOn)}
|
||||
{getTime(message.sendOn)}
|
||||
</div>
|
||||
</div>
|
||||
<div class="content-trans-color text-sm overflow-label mr-4 mb-4">
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import { 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 { IntegrationType, Handler } from '@anticrm/setting'
|
||||
|
||||
@ -27,6 +27,7 @@ export interface Message extends BaseMessage, AttachedDoc {
|
||||
from: string
|
||||
textContent: string
|
||||
incoming: boolean
|
||||
sendOn: Timestamp
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,6 +62,7 @@ export interface SharedMessage extends Doc {
|
||||
textContent: string
|
||||
attachments?: number
|
||||
copy?: string[]
|
||||
sendOn: Timestamp
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,8 +18,8 @@
|
||||
import { AttachmentRefInput } from '@anticrm/attachment-resources'
|
||||
import { Panel } from '@anticrm/panel'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import contact, { Channel, EmployeeAccount, formatName } from '@anticrm/contact'
|
||||
import { generateId, getCurrentAccount, Ref, SortingOrder, Space, Doc, Class } from '@anticrm/core'
|
||||
import contact, { Channel, Contact, EmployeeAccount, formatName } from '@anticrm/contact'
|
||||
import { generateId, getCurrentAccount, Ref, SortingOrder, Space, Class } from '@anticrm/core'
|
||||
import { NotificationClientImpl } from '@anticrm/notification-resources'
|
||||
import { createQuery, getClient } from '@anticrm/presentation'
|
||||
import setting, { Integration } from '@anticrm/setting'
|
||||
@ -32,11 +32,11 @@
|
||||
import Messages from './Messages.svelte'
|
||||
import Reconnect from './Reconnect.svelte'
|
||||
|
||||
export let _id: Ref<Doc>
|
||||
export let _class: Ref<Class<Doc>>
|
||||
export let _id: Ref<Contact>
|
||||
export let _class: Ref<Class<Contact>>
|
||||
export let rightSection: AnyComponent | undefined = undefined
|
||||
|
||||
let object: any
|
||||
let object: Contact
|
||||
let channel: Channel | undefined = undefined
|
||||
let objectId: Ref<NewTelegramMessage> = generateId()
|
||||
|
||||
@ -85,7 +85,7 @@
|
||||
updateAccountsQuery(accountsIds)
|
||||
},
|
||||
{
|
||||
sort: { modifiedOn: SortingOrder.Descending },
|
||||
sort: { sendOn: SortingOrder.Descending },
|
||||
limit: 500,
|
||||
lookup: {
|
||||
_id: { attachments: attachment.class.Attachment }
|
||||
|
@ -18,7 +18,7 @@
|
||||
export let message: SharedTelegramMessage
|
||||
|
||||
const current = new Date()
|
||||
const target = new Date(message.modifiedOn)
|
||||
const target = new Date(message.sendOn)
|
||||
let options: Intl.DateTimeFormatOptions = {
|
||||
day: 'numeric',
|
||||
month: 'long'
|
||||
@ -32,7 +32,7 @@
|
||||
</script>
|
||||
|
||||
<div class="datetime-container">
|
||||
{new Intl.DateTimeFormat('default', options).format(message.modifiedOn)}
|
||||
{new Intl.DateTimeFormat('default', options).format(message.sendOn)}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
|
@ -54,7 +54,7 @@
|
||||
<div class="flex">
|
||||
<div class="caption-color mr-4"><MessageViewer message={message.content} /></div>
|
||||
<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>
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
function isNewDate (messages: SharedTelegramMessage[], i: number): boolean {
|
||||
if (i === 0) return true
|
||||
const current = new Date(messages[i].modifiedOn).toLocaleDateString()
|
||||
const prev = new Date(messages[i - 1].modifiedOn).toLocaleDateString()
|
||||
const current = new Date(messages[i].sendOn).toLocaleDateString()
|
||||
const prev = new Date(messages[i - 1].sendOn).toLocaleDateString()
|
||||
return current !== prev
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
import { 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 { IntegrationType, Handler } from '@anticrm/setting'
|
||||
|
||||
@ -32,6 +32,8 @@ export interface BaseTelegramMessage extends Doc {
|
||||
*/
|
||||
export interface TelegramMessage extends BaseTelegramMessage, AttachedDoc {
|
||||
incoming: boolean
|
||||
|
||||
sendOn: Timestamp
|
||||
}
|
||||
|
||||
/**
|
||||
@ -47,6 +49,7 @@ export interface NewTelegramMessage extends BaseTelegramMessage, AttachedDoc {
|
||||
export interface SharedTelegramMessage extends BaseTelegramMessage {
|
||||
incoming: boolean
|
||||
sender: string
|
||||
sendOn: Timestamp
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user