From 667f26e7cd23ff697b187c24ae544118331fae13 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 15 Dec 2021 00:26:26 -0300 Subject: [PATCH] minor tweaks --- app/definitions/IRoom.ts | 3 +++ app/definitions/IThread.ts | 2 +- app/views/RoomView/index.tsx | 13 +++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index ed1852181..3c28b71a5 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -30,4 +30,7 @@ export interface IRoom extends IRocketChatRecord { usedCannedResponse?: string; bannerClosed?: boolean; lastOpen?: Date; + draftMessage?: string; } + +export type IRoomModel = IRoom & Model; diff --git a/app/definitions/IThread.ts b/app/definitions/IThread.ts index 9ff19de07..32e374718 100644 --- a/app/definitions/IThread.ts +++ b/app/definitions/IThread.ts @@ -27,7 +27,7 @@ export interface IThread { edited_by: { username: string }; reactions: IReaction[]; role: null; - drid: null; + drid: string; dcount: null; dlm: null; tmid: string; diff --git a/app/views/RoomView/index.tsx b/app/views/RoomView/index.tsx index ae261b3c3..488a60c1c 100644 --- a/app/views/RoomView/index.tsx +++ b/app/views/RoomView/index.tsx @@ -66,8 +66,9 @@ import UploadProgress from './UploadProgress'; import ReactionPicker from './ReactionPicker'; import List from './List'; import { ChatsStackParamList } from '../../stacks/types'; -import { IRoom, RoomType } from '../../definitions/IRoom'; +import { IRoom, IRoomModel, RoomType } from '../../definitions/IRoom'; import { IAttachment } from '../../definitions/IAttachment'; +import { IThread } from '../../definitions/IThread'; const stateAttrsUpdate = [ 'joined', @@ -364,7 +365,8 @@ class RoomView extends React.Component { this.mounted = false; if (!editing && this.messagebox && this.messagebox.current) { const { text } = this.messagebox.current; - let obj: any; // TODO - test the threadsCollection.find return to change this any; + let obj: IRoomModel = room; // TODO - test the threadsCollection.find return to change this any; + if (this.tmid) { try { const threadsCollection = db.get('threads'); @@ -372,13 +374,12 @@ class RoomView extends React.Component { } catch (e) { // Do nothing } - } else { - obj = room; } + if (obj) { try { await db.action(async () => { - await obj.update((r: any) => { + await obj.update(r => { // TODO - change this any r.draftMessage = text; }); @@ -742,7 +743,7 @@ class RoomView extends React.Component { }; onDiscussionPress = debounce( - (item: any) => { + (item: IThread) => { const { navigation } = this.props; navigation.push('RoomView', { rid: item.drid,