mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-18 16:31:57 +03:00
Fix chat red dots (#7440)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
57ee462ca6
commit
f265242c6f
@ -216,7 +216,8 @@ export class ChannelDataProvider implements IChannelDataProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateNewTimestamp (context?: DocNotifyContext): Promise<void> {
|
async updateNewTimestamp (context?: DocNotifyContext): Promise<void> {
|
||||||
this.context = context ?? this.context
|
if (context === undefined) return
|
||||||
|
this.context = context
|
||||||
const firstNewMsgIndex = await this.getFirstNewMsgIndex()
|
const firstNewMsgIndex = await this.getFirstNewMsgIndex()
|
||||||
const metadata = get(this.metadataStore)
|
const metadata = get(this.metadataStore)
|
||||||
this.newTimestampStore.set(firstNewMsgIndex !== undefined ? metadata[firstNewMsgIndex]?.createdOn : undefined)
|
this.newTimestampStore.set(firstNewMsgIndex !== undefined ? metadata[firstNewMsgIndex]?.createdOn : undefined)
|
||||||
|
@ -13,17 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import core, {
|
import core, { Doc, generateId, getCurrentAccount, Ref, Space, Timestamp, Tx, TxCUD } from '@hcengineering/core'
|
||||||
Doc,
|
|
||||||
generateId,
|
|
||||||
getCurrentAccount,
|
|
||||||
Ref,
|
|
||||||
Space,
|
|
||||||
Timestamp,
|
|
||||||
Tx,
|
|
||||||
TxCUD,
|
|
||||||
TxProcessor
|
|
||||||
} from '@hcengineering/core'
|
|
||||||
import activity, { ActivityMessage } from '@hcengineering/activity'
|
import activity, { ActivityMessage } from '@hcengineering/activity'
|
||||||
import { ModernButton, Scroller } from '@hcengineering/ui'
|
import { ModernButton, Scroller } from '@hcengineering/ui'
|
||||||
import { addTxListener, getClient, removeTxListener } from '@hcengineering/presentation'
|
import { addTxListener, getClient, removeTxListener } from '@hcengineering/presentation'
|
||||||
@ -236,7 +226,7 @@
|
|||||||
|
|
||||||
function scrollToStartOfNew (): void {
|
function scrollToStartOfNew (): void {
|
||||||
if (scrollDiv == null || lastMsgBeforeFreeze === undefined) return
|
if (scrollDiv == null || lastMsgBeforeFreeze === undefined) return
|
||||||
if (needUpdateTimestamp) {
|
if (needUpdateTimestamp || $newTimestampStore === undefined) {
|
||||||
void provider.updateNewTimestamp(notifyContext)
|
void provider.updateNewTimestamp(notifyContext)
|
||||||
needUpdateTimestamp = false
|
needUpdateTimestamp = false
|
||||||
}
|
}
|
||||||
@ -346,7 +336,7 @@
|
|||||||
|
|
||||||
function read (): void {
|
function read (): void {
|
||||||
if (isFreeze() || notifyContext === undefined || !isScrollInitialized) return
|
if (isFreeze() || notifyContext === undefined || !isScrollInitialized) return
|
||||||
readViewportMessages(messages, notifyContext, scrollDiv, contentDiv)
|
readViewportMessages(messages, notifyContext._id, scrollDiv, contentDiv)
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateScrollData (): void {
|
function updateScrollData (): void {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
import { getDay, type Timestamp } from '@hcengineering/core'
|
import { getDay, type Ref, type Timestamp } from '@hcengineering/core'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
import { sortActivityMessages } from '@hcengineering/activity-resources'
|
import { sortActivityMessages } from '@hcengineering/activity-resources'
|
||||||
import { type ActivityMessage, type DisplayActivityMessage } from '@hcengineering/activity'
|
import { type ActivityMessage, type DisplayActivityMessage } from '@hcengineering/activity'
|
||||||
@ -144,7 +144,7 @@ let messagesToReadAccumulatorTimer: any
|
|||||||
|
|
||||||
export function readViewportMessages (
|
export function readViewportMessages (
|
||||||
messages: ActivityMessage[],
|
messages: ActivityMessage[],
|
||||||
context: DocNotifyContext,
|
contextId: Ref<DocNotifyContext>,
|
||||||
scrollDiv?: HTMLElement | null,
|
scrollDiv?: HTMLElement | null,
|
||||||
contentDiv?: HTMLElement | null
|
contentDiv?: HTMLElement | null
|
||||||
): void {
|
): void {
|
||||||
@ -166,6 +166,6 @@ export function readViewportMessages (
|
|||||||
messagesToReadAccumulatorTimer = setTimeout(() => {
|
messagesToReadAccumulatorTimer = setTimeout(() => {
|
||||||
const messagesToRead = [...messagesToReadAccumulator]
|
const messagesToRead = [...messagesToReadAccumulator]
|
||||||
messagesToReadAccumulator.clear()
|
messagesToReadAccumulator.clear()
|
||||||
void readChannelMessages(sortActivityMessages(messagesToRead), context)
|
void readChannelMessages(sortActivityMessages(messagesToRead), contextId)
|
||||||
}, 500)
|
}, 500)
|
||||||
}
|
}
|
||||||
|
@ -429,13 +429,16 @@ export function recheckNotifications (context: DocNotifyContext): void {
|
|||||||
|
|
||||||
export async function readChannelMessages (
|
export async function readChannelMessages (
|
||||||
messages: DisplayActivityMessage[],
|
messages: DisplayActivityMessage[],
|
||||||
context: DocNotifyContext | undefined
|
contextId: Ref<DocNotifyContext>
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (messages.length === 0 || context === undefined) {
|
if (messages.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const inboxClient = InboxNotificationsClientImpl.getClient()
|
const inboxClient = InboxNotificationsClientImpl.getClient()
|
||||||
|
const context = get(inboxClient.contextById).get(contextId)
|
||||||
|
if (context === undefined) return
|
||||||
|
|
||||||
const op = getClient().apply(undefined, 'readViewportMessages', true)
|
const op = getClient().apply(undefined, 'readViewportMessages', true)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -464,7 +467,6 @@ export async function readChannelMessages (
|
|||||||
const prevTimestamp = Math.max(storedTimestampUpdates ?? 0, context.lastViewedTimestamp ?? 0)
|
const prevTimestamp = Math.max(storedTimestampUpdates ?? 0, context.lastViewedTimestamp ?? 0)
|
||||||
|
|
||||||
if (prevTimestamp < newTimestamp) {
|
if (prevTimestamp < newTimestamp) {
|
||||||
context.lastViewedTimestamp = newTimestamp
|
|
||||||
contextsTimestampStore.update((store) => {
|
contextsTimestampStore.update((store) => {
|
||||||
store.set(context._id, newTimestamp)
|
store.set(context._id, newTimestamp)
|
||||||
return store
|
return store
|
||||||
|
Loading…
Reference in New Issue
Block a user