2023-01-13 19:32:52 +00:00
|
|
|
import { loadMessagesForRoom, loadMissedMessages, RoomTypes } from '../../../lib/methods';
|
2022-03-02 14:18:01 +00:00
|
|
|
|
2023-01-13 19:32:52 +00:00
|
|
|
interface IBaseParams {
|
2022-03-02 14:18:01 +00:00
|
|
|
rid: string;
|
2023-01-13 19:32:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2022-03-02 14:18:01 +00:00
|
|
|
}
|
2023-01-13 19:32:52 +00:00
|
|
|
return loadMessagesForRoom(params);
|
2022-03-02 14:18:01 +00:00
|
|
|
};
|
2022-04-28 20:37:25 +00:00
|
|
|
|
2022-03-02 14:18:01 +00:00
|
|
|
export default getMessages;
|