Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UBER-1188: Fix exception during login/logout #4364

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
28 changes: 9 additions & 19 deletions plugins/notification-resources/src/inboxNotificationsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,17 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
import {
type Account,
type Class,
type Doc,
getCurrentAccount,
type Ref,
SortingOrder,
type WithLookup
} from '@hcengineering/core'
import { type ActivityMessage } from '@hcengineering/activity'
import { SortingOrder, getCurrentAccount, type Class, type Doc, type Ref, type WithLookup } from '@hcengineering/core'
import notification, {
type ActivityInboxNotification,
type Collaborators,
type DocNotifyContext,
type InboxNotification,
type InboxNotificationsClient
} from '@hcengineering/notification'
import { derived, writable } from 'svelte/store'
import { createQuery, getClient } from '@hcengineering/presentation'
import { type ActivityMessage } from '@hcengineering/activity'
import { derived, writable } from 'svelte/store'

/**
* @public
Expand Down Expand Up @@ -73,16 +65,14 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
private readonly docNotifyContextsQuery = createQuery(true)
private readonly inboxNotificationsQuery = createQuery(true)

private readonly _user: Ref<Account>
private _docNotifyContextByDoc = new Map<Ref<Doc>, DocNotifyContext>()
private _inboxNotifications: Array<WithLookup<InboxNotification>> = []

private constructor () {
this._user = getCurrentAccount()._id
this.docNotifyContextsQuery.query(
notification.class.DocNotifyContext,
{
user: this._user
user: getCurrentAccount()._id
},
(result: DocNotifyContext[]) => {
this.docNotifyContexts.set(result)
Expand All @@ -93,7 +83,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
this.inboxNotificationsQuery.query(
notification.class.InboxNotification,
{
user: this._user
user: getCurrentAccount()._id
},
(result: InboxNotification[]) => {
this.inboxNotifications.set(result)
Expand Down Expand Up @@ -162,18 +152,18 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
collaboratorsMixin.space,
notification.mixin.Collaborators,
{
collaborators: [this._user]
collaborators: [getCurrentAccount()._id]
}
)
} else if (!collaboratorsMixin.collaborators.includes(this._user)) {
} else if (!collaboratorsMixin.collaborators.includes(getCurrentAccount()._id)) {
await client.updateMixin(
collaboratorsMixin._id,
collaboratorsMixin._class,
collaboratorsMixin.space,
notification.mixin.Collaborators,
{
$push: {
collaborators: this._user
collaborators: getCurrentAccount()._id
}
}
)
Expand All @@ -182,7 +172,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
await client.createDoc(notification.class.DocNotifyContext, doc.space, {
attachedTo: _id,
attachedToClass: _class,
user: this._user,
user: getCurrentAccount()._id,
hidden: true
})
}
Expand Down