Skip to content

Commit

Permalink
Fix unread counter toast
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kudinov committed Aug 14, 2024
1 parent 134d30e commit 39097fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
4 changes: 2 additions & 2 deletions frontend/app/modules/layout-type/layout-type.store.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as SDK from '@expressms/smartapp-sdk'
import { makeAutoObservable, makeObservable, observable, runInAction } from 'mobx'
import { makeObservable, observable, runInAction } from 'mobx'
import { RootStore } from '../../store/rootStore'
import { GetLayoutTypeResponse, STATUS, SubscriptionEventType } from '@expressms/smartapp-sdk/build/main/types'
import { LayoutSubscriptionEvent } from './layout-type.types'

export class LayoutTypeStore {
rootStore: RootStore
@observable layoutType: string
callback: Function
callback: () => void

constructor(rootStore: RootStore) {
makeObservable(this)
Expand Down
15 changes: 11 additions & 4 deletions frontend/app/modules/unread-counters/unread-counters.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { EntityType, UnreadCounterSubscriptionEvent } from './unread-counters.ty
export class UnreadCountersStore {
rootStore: RootStore
unreadCounter: number | null
callback: Function
callback: () => void

constructor(rootStore: RootStore) {
makeAutoObservable(this)
Expand All @@ -18,7 +18,14 @@ export class UnreadCountersStore {
}

private unreadCounterCallback(event: UnreadCounterSubscriptionEvent) {
this.unreadCounter = event.payload.unreadCounter
const {
unreadCounter,
source: { type, id },
} = event.payload

this.unreadCounter = unreadCounter

this.rootStore.toastStore.showToast(`Счетчик = ${unreadCounter} для ${type} = ${id}`)
}

async getUnreadCounter(type: EntityType, id: string) {
Expand All @@ -45,7 +52,7 @@ export class UnreadCountersStore {
payload: {
type,
id,
}
},
})

console.log('Subscribed unread_counter_change')
Expand All @@ -58,7 +65,7 @@ export class UnreadCountersStore {
payload: {
type,
id,
}
},
})

console.log('Unubscribed unread_counter_change')
Expand Down
4 changes: 4 additions & 0 deletions frontend/app/modules/unread-counters/unread-counters.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ export type EntityType = 'huid' | 'chat' | 'smartapp'
export interface UnreadCounterSubscriptionEvent extends Omit<EmitterEventPayload, 'payload'> {
payload: {
unreadCounter: number
source: {
type: EntityType
id: string
}
}
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-feature-smartapp",
"version": "2.3.3",
"version": "2.3.4",
"description": "SmartApp with all features",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 39097fd

Please sign in to comment.