diff --git a/app/definitions/ISubscriptions.ts b/app/definitions/ISubscriptions.ts new file mode 100644 index 000000000..bba3b204f --- /dev/null +++ b/app/definitions/ISubscriptions.ts @@ -0,0 +1,13 @@ +import Model from '@nozbe/watermelondb/Model'; + +import { IRoom } from './IRoom'; + +export interface ISubscriptions { + _id: string; + name: string; + fname: string; + rid: string; + unread: number; +} + +export type ISubscriptionsModel = IRoom & Model; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index 488a60c1c..870338cfc 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -69,6 +69,7 @@ import { ChatsStackParamList } from '../../stacks/types'; import { IRoom, IRoomModel, RoomType } from '../../definitions/IRoom'; import { IAttachment } from '../../definitions/IAttachment'; import { IThread } from '../../definitions/IThread'; +import { ISubscriptions } from '../../definitions/ISubscriptions'; const stateAttrsUpdate = [ 'joined', @@ -764,9 +765,9 @@ class RoomView extends React.Component { .query(Q.where('archived', false), Q.where('open', true), Q.where('rid', Q.notEq(this.rid))) .observeWithColumns(['unread']); - this.queryUnreads = observable.subscribe((data: any) => { + this.queryUnreads = observable.subscribe((data: ISubscriptions[]) => { const { unreadsCount } = this.state; - const newUnreadsCount = data.filter((s: any) => s.unread > 0).reduce((a: any, b: any) => a + (b.unread || 0), 0); + const newUnreadsCount = data.filter(s => s.unread > 0).reduce((a, b) => a + (b.unread || 0), 0); if (unreadsCount !== newUnreadsCount) { this.setState({ unreadsCount: newUnreadsCount }, () => this.setHeader()); }