vn-verdnaturachat/app/views/RoomView/services/getMessages.ts

23 lines
531 B
TypeScript
Raw Normal View History

import { loadMessagesForRoom, loadMissedMessages, RoomTypes } from '../../../lib/methods';
interface IBaseParams {
rid: string;
}
interface ILoadMessagesForRoomParams extends IBaseParams {
t: RoomTypes;
}
interface ILoadMissedMessagesParams extends IBaseParams {
lastOpen: Date;
}
const getMessages = (params: ILoadMissedMessagesParams | ILoadMessagesForRoomParams): Promise<void> => {
if ('lastOpen' in params) {
return loadMissedMessages(params);
}
return loadMessagesForRoom(params);
};
export default getMessages;