Chore: Server API types - chat.getDiscussions (#3776)
* chore: implementing type for test api - getDiscussions * Fix DiscussionDetails count usage * chore: update getDiscussions to use IMessageFromServer Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
09f73aee3d
commit
b2bd71e83e
|
@ -83,6 +83,10 @@ export interface IMessageFromServer {
|
|||
files?: IMessageFile[];
|
||||
groupable?: boolean;
|
||||
attachments?: IAttachment[];
|
||||
t?: MessageType;
|
||||
drid?: string;
|
||||
dcount?: number;
|
||||
dml: string | Date;
|
||||
}
|
||||
|
||||
export interface ILoadMoreMessage {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { IMessage } from '../../IMessage';
|
||||
import type { IMessage, IMessageFromServer } from '../../IMessage';
|
||||
import type { IServerRoom } from '../../IRoom';
|
||||
import { PaginatedResult } from '../helpers/PaginatedResult';
|
||||
|
||||
|
@ -31,7 +31,7 @@ export type ChatEndpoints = {
|
|||
};
|
||||
'chat.getDiscussions': {
|
||||
GET: (params: { roomId: IServerRoom['_id']; text?: string; offset: number; count: number }) => {
|
||||
messages: IMessage[];
|
||||
messages: IMessageFromServer[];
|
||||
total: number;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import React from 'react';
|
||||
import { StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
import { TThreadModel } from '../../definitions/IThread';
|
||||
import { CustomIcon } from '../../lib/Icons';
|
||||
import { themes } from '../../constants/colors';
|
||||
import sharedStyles from '../Styles';
|
||||
import { useTheme } from '../../theme';
|
||||
import { IMessageFromServer } from '../../definitions';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
@ -31,7 +31,7 @@ const styles = StyleSheet.create({
|
|||
});
|
||||
|
||||
interface IDiscussionDetails {
|
||||
item: TThreadModel;
|
||||
item: IMessageFromServer;
|
||||
date: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { themes } from '../../constants/colors';
|
|||
import { MarkdownPreview } from '../../containers/markdown';
|
||||
import { formatDateThreads, makeThreadName } from '../../utils/room';
|
||||
import DiscussionDetails from './DiscussionDetails';
|
||||
import { TThreadModel } from '../../definitions/IThread';
|
||||
import { IMessageFromServer } from '../../definitions';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
|
@ -48,7 +48,7 @@ const styles = StyleSheet.create({
|
|||
});
|
||||
|
||||
interface IItem {
|
||||
item: TThreadModel;
|
||||
item: IMessageFromServer;
|
||||
onPress: {
|
||||
(...args: any[]): void;
|
||||
stop(): void;
|
||||
|
|
|
@ -5,7 +5,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|||
import { HeaderBackButton, StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack';
|
||||
import { RouteProp } from '@react-navigation/core';
|
||||
|
||||
import { IApplicationState } from '../../definitions';
|
||||
import { IApplicationState, IMessageFromServer } from '../../definitions';
|
||||
import { ChatsStackParamList } from '../../stacks/types';
|
||||
import ActivityIndicator from '../../containers/ActivityIndicator';
|
||||
import I18n from '../../i18n';
|
||||
|
@ -47,8 +47,8 @@ const DiscussionsView = ({ navigation, route }: IDiscussionsViewProps): JSX.Elem
|
|||
const isMasterDetail = useSelector((state: IApplicationState) => state.app?.isMasterDetail);
|
||||
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [discussions, setDiscussions] = useState([]);
|
||||
const [search, setSearch] = useState([]);
|
||||
const [discussions, setDiscussions] = useState<IMessageFromServer[]>([]);
|
||||
const [search, setSearch] = useState<IMessageFromServer[]>([]);
|
||||
const [isSearching, setIsSearching] = useState(false);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [searchTotal, setSearchTotal] = useState(0);
|
||||
|
@ -63,7 +63,7 @@ const DiscussionsView = ({ navigation, route }: IDiscussionsViewProps): JSX.Elem
|
|||
|
||||
setLoading(true);
|
||||
try {
|
||||
const result: any = await RocketChat.getDiscussions({
|
||||
const result = await RocketChat.getDiscussions({
|
||||
roomId: rid,
|
||||
offset: isSearching ? search.length : discussions.length,
|
||||
count: API_FETCH_COUNT,
|
||||
|
@ -171,7 +171,7 @@ const DiscussionsView = ({ navigation, route }: IDiscussionsViewProps): JSX.Elem
|
|||
true
|
||||
);
|
||||
|
||||
const renderItem = ({ item }: { item: TThreadModel }) => (
|
||||
const renderItem = ({ item }: { item: IMessageFromServer }) => (
|
||||
<Item
|
||||
{...{
|
||||
item,
|
||||
|
|
Loading…
Reference in New Issue