From 4b9ed36fa5f518da1d7fa32a4b6fc1bffac15373 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 15 Dec 2021 23:35:33 -0300 Subject: [PATCH] minor tweak and fix the ISubscriptions interface --- app/definitions/ISubscriptions.ts | 7 ++++--- app/views/RoomView/RightButtons.tsx | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/definitions/ISubscriptions.ts b/app/definitions/ISubscriptions.ts index bba3b204f..cd9ae19fd 100644 --- a/app/definitions/ISubscriptions.ts +++ b/app/definitions/ISubscriptions.ts @@ -1,13 +1,14 @@ import Model from '@nozbe/watermelondb/Model'; -import { IRoom } from './IRoom'; - export interface ISubscriptions { _id: string; name: string; fname: string; rid: string; unread: number; + tunread: string; + tunreadUser: string; + tunreadGroup: string; } -export type ISubscriptionsModel = IRoom & Model; +export type TSubscriptionsModel = ISubscriptions & Model; diff --git a/app/views/RoomView/RightButtons.tsx b/app/views/RoomView/RightButtons.tsx index c97e14ecf..4279a43cf 100644 --- a/app/views/RoomView/RightButtons.tsx +++ b/app/views/RoomView/RightButtons.tsx @@ -2,7 +2,6 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { dequal } from 'dequal'; import { Subscription } from 'rxjs'; -import Model from '@nozbe/watermelondb/Model'; import { StackNavigationProp } from '@react-navigation/stack'; import * as HeaderButton from '../../containers/HeaderButton'; @@ -12,6 +11,8 @@ import { events, logEvent } from '../../utils/log'; import { isTeamRoom } from '../../utils/room'; import { ChatsStackParamList } from '../../stacks/types'; import { RoomType } from '../../definitions/IRoom'; +import { IThread, TThreadModel } from '../../definitions/IThread'; +import { ISubscriptions, TSubscriptionsModel } from '../../definitions/ISubscriptions'; interface IRoomRightButtonsContainerProps { userId: string; @@ -93,26 +94,26 @@ class RightButtonsContainer extends Component { + observeThread = (threadRecord: TThreadModel) => { const threadObservable = threadRecord.observe(); this.threadSubscription = threadObservable.subscribe(thread => this.updateThread(thread)); }; - updateThread = (thread: any) => { + updateThread = (thread: IThread) => { const { userId } = this.props; this.setState({ isFollowingThread: thread.replies && !!thread.replies.find((t: string) => t === userId) }); }; - observeSubscription = (subRecord: Model) => { + observeSubscription = (subRecord: TSubscriptionsModel) => { const subObservable = subRecord.observe(); this.subSubscription = subObservable.subscribe(sub => { this.updateSubscription(sub); }); }; - updateSubscription = (sub: any) => { + updateSubscription = (sub: ISubscriptions) => { this.setState({ tunread: sub?.tunread, tunreadUser: sub?.tunreadUser,