Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions plugins/notification-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,13 @@ export function getDisplayInboxData (
export function getInboxNotificationStore (): Readable<InboxNotificationState> {
const inboxClient = InboxNotificationsClientImpl.getClient()

return derived(inboxClient.inboxNotificationsByContext, (notificationsByContext) => ({
notify: getDisplayInboxData(notificationsByContext, 'unread').size > 0
}))
return derived(
[inboxClient.inboxNotificationsByContext, inboxClient.isLoaded],
([notificationsByContext, isLoaded]) => ({
notify: getDisplayInboxData(notificationsByContext, 'unread').size > 0,
isLoaded
})
)
}

export async function getNotificationsCount (
Expand Down
1 change: 1 addition & 0 deletions plugins/notification/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const DOMAIN_USER_NOTIFY = 'notification-user' as Domain
export interface InboxNotificationState {
notify: boolean
count?: number
isLoaded?: boolean
}

/**
Expand Down
12 changes: 12 additions & 0 deletions plugins/workbench-resources/src/components/Workbench.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!--
// Copyright © 2022, 2023 Hardcore Engineering Inc.
// Copyright © 2026 TraceX SAS.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
Expand Down Expand Up @@ -108,6 +109,7 @@
isAllowedToRole,
logOut,
refreshWorkspaces,
reportWorkspaceRead,
workspacesStore
} from '../utils'
import AccountPopup from './AccountPopup.svelte'
Expand Down Expand Up @@ -297,6 +299,7 @@
const workspaceId = $location.path[1]

let hasInboxNotifications = false
let clearedWorkspaceUnread = false
let unsubscribeInboxNotifications: (() => void) | undefined
let isDestroyed = false

Expand All @@ -305,6 +308,15 @@
if (isDestroyed) return

unsubscribeInboxNotifications = createInboxNotificationStore().subscribe((state) => {
if (!state.isLoaded) return

if (!state.notify && !clearedWorkspaceUnread) {
clearedWorkspaceUnread = true
void reportWorkspaceRead()
} else if (state.notify) {
clearedWorkspaceUnread = false
}

hasInboxNotifications = state.notify
})
})
Expand Down