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