chore: migrate services room to ts

This commit is contained in:
AlexAlexandre 2021-12-03 18:26:47 -03:00
parent a6146bd02b
commit 8239c4489a
8 changed files with 19 additions and 18 deletions

View File

@ -2,7 +2,7 @@ import { getMessageById } from '../../../lib/database/services/Message';
import { getThreadMessageById } from '../../../lib/database/services/ThreadMessage';
import getSingleMessage from '../../../lib/methods/getSingleMessage';
const getMessageInfo = async messageId => {
const getMessageInfo = async (messageId: string) => {
let result;
result = await getMessageById(messageId);
if (result) {

View File

@ -1,10 +0,0 @@
import RocketChat from '../../../lib/rocketchat';
const getMessages = room => {
if (room.lastOpen) {
return RocketChat.loadMissedMessages(room);
} else {
return RocketChat.loadMessagesForRoom(room);
}
};
export default getMessages;

View File

@ -0,0 +1,10 @@
import RocketChat from '../../../lib/rocketchat';
// TODO - after merge navigation ts, change the room and the promisse return
const getMessages = (room: any): Promise<any> => {
if (room.lastOpen) {
return RocketChat.loadMissedMessages(room);
}
return RocketChat.loadMessagesForRoom(room);
};
export default getMessages;

View File

@ -5,7 +5,8 @@ import {
} from '../../../constants/messageTypeLoad';
import RocketChat from '../../../lib/rocketchat';
const getMoreMessages = ({ rid, t, tmid, loaderItem }) => {
// TODO - after merge navigation ts
const getMoreMessages = ({ rid, t, tmid, loaderItem }: any) => {
if ([MESSAGE_TYPE_LOAD_MORE, MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK].includes(loaderItem.t)) {
return RocketChat.loadMessagesForRoom({
rid,

View File

@ -1,6 +1,6 @@
import RocketChat from '../../../lib/rocketchat';
// unlike getMessages, sync isn't required for threads, because loadMissedMessages does it already
const getThreadMessages = (tmid, rid) => RocketChat.loadThreadMessages({ tmid, rid });
const getThreadMessages = (tmid: string, rid: string) => RocketChat.loadThreadMessages({ tmid, rid });
export default getThreadMessages;

View File

@ -1,5 +0,0 @@
import RocketChat from '../../../lib/rocketchat';
const readMessages = (rid, newLastOpen) => RocketChat.readMessages(rid, newLastOpen, true);
export default readMessages;

View File

@ -0,0 +1,5 @@
import RocketChat from '../../../lib/rocketchat';
const readMessages = (rid: string, newLastOpen: string): Promise<void> => RocketChat.readMessages(rid, newLastOpen, true);
export default readMessages;