Chore: Migrate REST API - getReadReceipts to Typescript (#3877)

This commit is contained in:
Reinaldo Neto 2022-03-14 10:32:22 -03:00 committed by GitHub
parent cfb10ada60
commit 7bf0de5825
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 19 deletions

View File

@ -147,3 +147,13 @@ export type TMessageModel = IMessage & Model;
export type TAnyMessageModel = TMessageModel | TThreadModel | TThreadMessageModel; export type TAnyMessageModel = TMessageModel | TThreadModel | TThreadMessageModel;
export type TTypeMessages = IMessageFromServer | ILoadMoreMessage | IMessage; export type TTypeMessages = IMessageFromServer | ILoadMoreMessage | IMessage;
// Read receipts to ReadReceiptView and chat.getMessageReadReceipts
export interface IReadReceipts {
_id: string;
roomId: string;
userId: string;
messageId: string;
ts: string;
user?: IUserMessage;
}

View File

@ -1,4 +1,4 @@
import type { IMessage, IMessageFromServer } from '../../IMessage'; import type { IMessage, IMessageFromServer, IReadReceipts } from '../../IMessage';
import type { IServerRoom } from '../../IRoom'; import type { IServerRoom } from '../../IRoom';
import { PaginatedResult } from '../helpers/PaginatedResult'; import { PaginatedResult } from '../helpers/PaginatedResult';
@ -65,4 +65,7 @@ export type ChatEndpoints = {
messages: IMessageFromServer[]; messages: IMessageFromServer[];
}; };
}; };
'chat.getMessageReadReceipts': {
GET: (params: { messageId: string }) => { receipts: IReadReceipts[] };
};
}; };

View File

@ -617,10 +617,8 @@ export const getMessages = (
}); });
}; };
export const getReadReceipts = (messageId: string): any => export const getReadReceipts = (messageId: string) =>
// RC 0.63.0 // RC 0.63.0
// TODO: missing definitions from server
// @ts-ignore
sdk.get('chat.getMessageReadReceipts', { sdk.get('chat.getMessageReadReceipts', {
messageId messageId
}); });

View File

@ -17,23 +17,11 @@ import { themes } from '../../constants/colors';
import SafeAreaView from '../../containers/SafeAreaView'; import SafeAreaView from '../../containers/SafeAreaView';
import styles from './styles'; import styles from './styles';
import { ChatsStackParamList } from '../../stacks/types'; import { ChatsStackParamList } from '../../stacks/types';
import { IReadReceipts } from '../../definitions';
interface IReceipts {
_id: string;
roomId: string;
userId: string;
messageId: string;
ts: string;
user?: {
_id: string;
name: string;
username: string;
};
}
interface IReadReceiptViewState { interface IReadReceiptViewState {
loading: boolean; loading: boolean;
receipts: IReceipts[]; receipts: IReadReceipts[];
} }
interface INavigationOption { interface INavigationOption {
@ -125,7 +113,7 @@ class ReadReceiptView extends React.Component<IReadReceiptViewProps, IReadReceip
); );
}; };
renderItem = ({ item }: { item: IReceipts }) => { renderItem = ({ item }: { item: IReadReceipts }) => {
const { theme, Message_TimeAndDateFormat } = this.props; const { theme, Message_TimeAndDateFormat } = this.props;
const time = moment(item.ts).format(Message_TimeAndDateFormat); const time = moment(item.ts).format(Message_TimeAndDateFormat);
if (!item?.user?.username) { if (!item?.user?.username) {