Fix chat red dots (#7440)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-12-12 15:31:26 +04:00 committed by GitHub
parent 57ee462ca6
commit f265242c6f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 20 deletions

View File

@ -216,7 +216,8 @@ export class ChannelDataProvider implements IChannelDataProvider {
}
async updateNewTimestamp (context?: DocNotifyContext): Promise<void> {
this.context = context ?? this.context
if (context === undefined) return
this.context = context
const firstNewMsgIndex = await this.getFirstNewMsgIndex()
const metadata = get(this.metadataStore)
this.newTimestampStore.set(firstNewMsgIndex !== undefined ? metadata[firstNewMsgIndex]?.createdOn : undefined)

View File

@ -13,17 +13,7 @@
// limitations under the License.
-->
<script lang="ts">
import core, {
Doc,
generateId,
getCurrentAccount,
Ref,
Space,
Timestamp,
Tx,
TxCUD,
TxProcessor
} from '@hcengineering/core'
import core, { Doc, generateId, getCurrentAccount, Ref, Space, Timestamp, Tx, TxCUD } from '@hcengineering/core'
import activity, { ActivityMessage } from '@hcengineering/activity'
import { ModernButton, Scroller } from '@hcengineering/ui'
import { addTxListener, getClient, removeTxListener } from '@hcengineering/presentation'
@ -236,7 +226,7 @@
function scrollToStartOfNew (): void {
if (scrollDiv == null || lastMsgBeforeFreeze === undefined) return
if (needUpdateTimestamp) {
if (needUpdateTimestamp || $newTimestampStore === undefined) {
void provider.updateNewTimestamp(notifyContext)
needUpdateTimestamp = false
}
@ -346,7 +336,7 @@
function read (): void {
if (isFreeze() || notifyContext === undefined || !isScrollInitialized) return
readViewportMessages(messages, notifyContext, scrollDiv, contentDiv)
readViewportMessages(messages, notifyContext._id, scrollDiv, contentDiv)
}
function updateScrollData (): void {

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// 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 { sortActivityMessages } from '@hcengineering/activity-resources'
import { type ActivityMessage, type DisplayActivityMessage } from '@hcengineering/activity'
@ -144,7 +144,7 @@ let messagesToReadAccumulatorTimer: any
export function readViewportMessages (
messages: ActivityMessage[],
context: DocNotifyContext,
contextId: Ref<DocNotifyContext>,
scrollDiv?: HTMLElement | null,
contentDiv?: HTMLElement | null
): void {
@ -166,6 +166,6 @@ export function readViewportMessages (
messagesToReadAccumulatorTimer = setTimeout(() => {
const messagesToRead = [...messagesToReadAccumulator]
messagesToReadAccumulator.clear()
void readChannelMessages(sortActivityMessages(messagesToRead), context)
void readChannelMessages(sortActivityMessages(messagesToRead), contextId)
}, 500)
}

View File

@ -429,13 +429,16 @@ export function recheckNotifications (context: DocNotifyContext): void {
export async function readChannelMessages (
messages: DisplayActivityMessage[],
context: DocNotifyContext | undefined
contextId: Ref<DocNotifyContext>
): Promise<void> {
if (messages.length === 0 || context === undefined) {
if (messages.length === 0) {
return
}
const inboxClient = InboxNotificationsClientImpl.getClient()
const context = get(inboxClient.contextById).get(contextId)
if (context === undefined) return
const op = getClient().apply(undefined, 'readViewportMessages', true)
try {
@ -464,7 +467,6 @@ export async function readChannelMessages (
const prevTimestamp = Math.max(storedTimestampUpdates ?? 0, context.lastViewedTimestamp ?? 0)
if (prevTimestamp < newTimestamp) {
context.lastViewedTimestamp = newTimestamp
contextsTimestampStore.update((store) => {
store.set(context._id, newTimestamp)
return store