From c1cfa647b372ebd9c2fb42aca6f8fec08a5ec91e Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Tue, 2 Nov 2021 14:46:32 -0400 Subject: [PATCH 01/23] create types --- app/definition/IRocketChatRecord.ts | 4 + app/definition/IRoom.ts | 22 +++ .../{InsideStack.js => InsideStack.tsx} | 66 ++++---- app/stacks/types.ts | 150 ++++++++++++++++++ app/views/InviteUsersEditView/index.js | 4 +- app/views/InviteUsersView/index.tsx | 11 +- 6 files changed, 223 insertions(+), 34 deletions(-) create mode 100644 app/definition/IRocketChatRecord.ts create mode 100644 app/definition/IRoom.ts rename app/stacks/{InsideStack.js => InsideStack.tsx} (85%) create mode 100644 app/stacks/types.ts diff --git a/app/definition/IRocketChatRecord.ts b/app/definition/IRocketChatRecord.ts new file mode 100644 index 00000000000..0dc3f5f5116 --- /dev/null +++ b/app/definition/IRocketChatRecord.ts @@ -0,0 +1,4 @@ +export interface IRocketChatRecord { + _id: string; + _updatedAt: Date; +} diff --git a/app/definition/IRoom.ts b/app/definition/IRoom.ts new file mode 100644 index 00000000000..994835dc322 --- /dev/null +++ b/app/definition/IRoom.ts @@ -0,0 +1,22 @@ +import { IRocketChatRecord } from './IRocketChatRecord'; + +export enum RoomType { + GROUP = 'p', + DIRECT = 'd', + CHANNEL = 'c', + OMNICHANNEL = 'l' +} + +export interface IRoom extends IRocketChatRecord { + rid: string; + t: RoomType; + name: string; + fname: string; + prid?: string; + tmid?: string; + topic?: string; + teamMain?: boolean; + teamId?: string; + encrypted?: boolean; + visitor?: boolean; +} diff --git a/app/stacks/InsideStack.js b/app/stacks/InsideStack.tsx similarity index 85% rename from app/stacks/InsideStack.js rename to app/stacks/InsideStack.tsx index b3de1b610b0..66967f71ba1 100644 --- a/app/stacks/InsideStack.js +++ b/app/stacks/InsideStack.tsx @@ -1,12 +1,11 @@ import React from 'react'; import { I18nManager } from 'react-native'; -import { createStackNavigator } from '@react-navigation/stack'; +import { createStackNavigator, StackNavigationOptions } from '@react-navigation/stack'; import { createDrawerNavigator } from '@react-navigation/drawer'; import { ThemeContext } from '../theme'; import { ModalAnimation, StackAnimation, defaultHeader, themedHeader } from '../utils/navigation'; import Sidebar from '../views/SidebarView'; - // Chats Stack import RoomView from '../views/RoomView'; import RoomsListView from '../views/RoomsListView'; @@ -37,10 +36,8 @@ import { themes } from '../constants/colors'; import ProfileView from '../views/ProfileView'; import UserPreferencesView from '../views/UserPreferencesView'; import UserNotificationPrefView from '../views/UserNotificationPreferencesView'; - // Display Preferences View import DisplayPrefsView from '../views/DisplayPrefsView'; - // Settings Stack import SettingsView from '../views/SettingsView'; import SecurityPrivacyView from '../views/SecurityPrivacyView'; @@ -49,21 +46,16 @@ import LanguageView from '../views/LanguageView'; import ThemeView from '../views/ThemeView'; import DefaultBrowserView from '../views/DefaultBrowserView'; import ScreenLockConfigView from '../views/ScreenLockConfigView'; - // Admin Stack import AdminPanelView from '../views/AdminPanelView'; - // NewMessage Stack import NewMessageView from '../views/NewMessageView'; import CreateChannelView from '../views/CreateChannelView'; - // E2ESaveYourPassword Stack import E2ESaveYourPasswordView from '../views/E2ESaveYourPasswordView'; import E2EHowItWorksView from '../views/E2EHowItWorksView'; - // E2EEnterYourPassword Stack import E2EEnterYourPasswordView from '../views/E2EEnterYourPasswordView'; - // InsideStackNavigator import AttachmentView from '../views/AttachmentView'; import ModalBlockView from '../views/ModalBlockView'; @@ -75,13 +67,26 @@ import QueueListView from '../ee/omnichannel/views/QueueListView'; import AddChannelTeamView from '../views/AddChannelTeamView'; import AddExistingChannelView from '../views/AddExistingChannelView'; import SelectListView from '../views/SelectListView'; +import { + AdminPanelStackParamList, + ChatsStackParamList, + DisplayPrefStackParamList, + DrawerParamList, + E2EEnterYourPasswordStackParamList, + E2ESaveYourPasswordStackParamList, + InsideStackParamList, + NewMessageStackParamList, + ProfileStackParamList, + SettingsStackParamList +} from './types'; // ChatsStackNavigator -const ChatsStack = createStackNavigator(); +const ChatsStack = createStackNavigator(); const ChatsStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + @@ -156,11 +161,12 @@ const ChatsStackNavigator = () => { }; // ProfileStackNavigator -const ProfileStack = createStackNavigator(); +const ProfileStack = createStackNavigator(); const ProfileStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + { }; // SettingsStackNavigator -const SettingsStack = createStackNavigator(); +const SettingsStack = createStackNavigator(); const SettingsStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + { }; // AdminPanelStackNavigator -const AdminPanelStack = createStackNavigator(); +const AdminPanelStack = createStackNavigator(); const AdminPanelStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + ); }; // DisplayPreferenceNavigator -const DisplayPrefStack = createStackNavigator(); +const DisplayPrefStack = createStackNavigator(); const DisplayPrefStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + ); }; // DrawerNavigator -const Drawer = createDrawerNavigator(); +const Drawer = createDrawerNavigator(); const DrawerNavigator = () => { const { theme } = React.useContext(ThemeContext); @@ -257,12 +266,13 @@ const DrawerNavigator = () => { }; // NewMessageStackNavigator -const NewMessageStack = createStackNavigator(); +const NewMessageStack = createStackNavigator(); const NewMessageStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + { }; // E2ESaveYourPasswordStackNavigator -const E2ESaveYourPasswordStack = createStackNavigator(); +const E2ESaveYourPasswordStack = createStackNavigator(); const E2ESaveYourPasswordStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + { }; // E2EEnterYourPasswordStackNavigator -const E2EEnterYourPasswordStack = createStackNavigator(); +const E2EEnterYourPasswordStack = createStackNavigator(); const E2EEnterYourPasswordStackNavigator = () => { const { theme } = React.useContext(ThemeContext); return ( - + { }; // InsideStackNavigator -const InsideStack = createStackNavigator(); +const InsideStack = createStackNavigator(); const InsideStackNavigator = () => { const { theme } = React.useContext(ThemeContext); diff --git a/app/stacks/types.ts b/app/stacks/types.ts new file mode 100644 index 00000000000..4fd9a6faee0 --- /dev/null +++ b/app/stacks/types.ts @@ -0,0 +1,150 @@ +import { IRoom, RoomType } from '../definition/IRoom'; + +export type ChatsStackParamList = { + RoomsListView: undefined; + RoomView: { + rid: string; + t: RoomType; + tmid?: string; + message?: string; + name: string; + fname: string; + prid?: string; + room: IRoom; + jumpToMessageId?: string; + jumpToThreadId?: string; + roomUserId: string; + }; + RoomActionsView: { + room: IRoom; + member: any; + rid: string; + t: RoomType; + joined: boolean; + }; + SelectListView: { + data: any; + title: string; + infoText: string; + nextAction: Function; + showAlert: boolean; + isSearch: boolean; + onSearch: Function; + isRadio?: boolean; + }; + RoomInfoView: { + room: IRoom; + member: any; + rid: string; + t: RoomType; + }; + RoomInfoEditView: { + rid: string; + }; + RoomMembersView: { + rid: string; + room: IRoom; + }; + SearchMessagesView: { + rid: string; + t: RoomType; + encrypted?: boolean; + showCloseModal?: boolean; + }; + SelectedUsersView: { + maxUsers: number; + showButton: boolean; + title: string; + buttonText: string; + nextAction: Function; + }; + InviteUsersView: { + rid: string; + }; + InviteUsersEditView: { + rid: string; + }; + MessagesView: { + rid: string; + t: RoomType; + name: string; + }; + AutoTranslateView: {}; + DirectoryView: {}; + NotificationPrefView: {}; + VisitorNavigationView: {}; + ForwardLivechatView: {}; + LivechatEditView: {}; + PickerView: {}; + ThreadMessagesView: {}; + TeamChannelsView: {}; + CreateChannelView: {}; + AddChannelTeamView: {}; + AddExistingChannelView: {}; + MarkdownTableView: {}; + ReadReceiptsView: {}; + QueueListView: {}; + CannedResponsesListView: {}; + CannedResponseDetail: {}; +}; + +export type ProfileStackParamList = { + ProfileView: {}; + UserPreferencesView: {}; + UserNotificationPrefView: {}; + PickerView: {}; +}; + +export type SettingsStackParamList = { + SettingsView: {}; + SecurityPrivacyView: {}; + E2EEncryptionSecurityView: {}; + LanguageView: {}; + ThemeView: {}; + DefaultBrowserView: {}; + ScreenLockConfigView: {}; +}; + +export type AdminPanelStackParamList = { + AdminPanelView: {}; +}; + +export type DisplayPrefStackParamList = { + DisplayPrefsView: {}; +}; + +export type DrawerParamList = { + ChatsStackNavigator: ChatsStackParamList; + ProfileStackNavigator: ProfileStackParamList; + SettingsStackNavigator: SettingsStackParamList; + AdminPanelStackNavigator: AdminPanelStackParamList; + DisplayPrefStackNavigator: DisplayPrefStackParamList; +}; + +export type NewMessageStackParamList = { + NewMessageView: {}; + SelectedUsersViewCreateChannel: {}; // to change + CreateChannelView: {}; + CreateDiscussionView: {}; +}; + +export type E2ESaveYourPasswordStackParamList = { + E2ESaveYourPasswordView: {}; + E2EHowItWorksView: {}; +}; + +export type E2EEnterYourPasswordStackParamList = { + E2EEnterYourPasswordView: {}; +}; + +export type InsideStackParamList = { + DrawerNavigator: DrawerParamList; + NewMessageStackNavigator: NewMessageStackParamList; + E2ESaveYourPasswordStackNavigator: E2ESaveYourPasswordStackParamList; + E2EEnterYourPasswordStackNavigator: E2EEnterYourPasswordStackParamList; + AttachmentView: {}; + StatusView: {}; + ShareView: {}; + ModalBlockView: {}; + JitsiMeetView: {}; +}; diff --git a/app/views/InviteUsersEditView/index.js b/app/views/InviteUsersEditView/index.js index 105a8809de5..02476e0ac5c 100644 --- a/app/views/InviteUsersEditView/index.js +++ b/app/views/InviteUsersEditView/index.js @@ -65,7 +65,7 @@ const OPTIONS = { ] }; -class InviteUsersView extends React.Component { +class InviteUsersEditView extends React.Component { static navigationOptions = () => ({ title: I18n.t('Invite_users') }); @@ -153,4 +153,4 @@ const mapDispatchToProps = dispatch => ({ createInviteLink: rid => dispatch(inviteLinksCreateAction(rid)) }); -export default connect(mapStateToProps, mapDispatchToProps)(withTheme(InviteUsersView)); +export default connect(mapStateToProps, mapDispatchToProps)(withTheme(InviteUsersEditView)); diff --git a/app/views/InviteUsersView/index.tsx b/app/views/InviteUsersView/index.tsx index cfcd3fa11e0..b7bf3071009 100644 --- a/app/views/InviteUsersView/index.tsx +++ b/app/views/InviteUsersView/index.tsx @@ -6,6 +6,7 @@ import { StackNavigationProp, StackNavigationOptions } from '@react-navigation/s import { RouteProp } from '@react-navigation/core'; import { Dispatch } from 'redux'; +import { ChatsStackParamList } from '../../stacks/types'; import { inviteLinksClear as inviteLinksClearAction, inviteLinksCreate as inviteLinksCreateAction @@ -22,9 +23,9 @@ import SafeAreaView from '../../containers/SafeAreaView'; import { events, logEvent } from '../../utils/log'; import styles from './styles'; -interface IInviteUsersView { - navigation: StackNavigationProp; - route: RouteProp; +interface IInviteUsersViewProps { + navigation: StackNavigationProp; + route: RouteProp; theme: string; timeDateFormat: string; invite: { @@ -36,14 +37,14 @@ interface IInviteUsersView { createInviteLink(rid: string): void; clearInviteLink(): void; } -class InviteUsersView extends React.Component { +class InviteUsersView extends React.Component { private rid: string; static navigationOptions: StackNavigationOptions = { title: I18n.t('Invite_users') }; - constructor(props: IInviteUsersView) { + constructor(props: IInviteUsersViewProps) { super(props); this.rid = props.route.params?.rid; } From 3926244dc18eb654bacae2cf5f76bf2757180e62 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 3 Nov 2021 15:50:06 -0400 Subject: [PATCH 02/23] Update navigation interface for some components and global navigation types --- app/containers/SearchBox.tsx | 4 +- app/definition/IAttachment.ts | 8 + app/definition/IMessage.ts | 3 + app/definition/IRocketChatRecord.ts | 4 +- app/definition/IRoom.ts | 4 + app/stacks/types.ts | 173 ++++++++++++++----- app/views/AdminPanelView/index.tsx | 3 +- app/views/AutoTranslateView/index.tsx | 16 +- app/views/CreateDiscussionView/index.tsx | 11 +- app/views/CreateDiscussionView/interfaces.ts | 17 +- app/views/DirectoryView/index.tsx | 4 +- app/views/SettingsView/index.tsx | 9 +- 12 files changed, 177 insertions(+), 79 deletions(-) create mode 100644 app/definition/IAttachment.ts create mode 100644 app/definition/IMessage.ts diff --git a/app/containers/SearchBox.tsx b/app/containers/SearchBox.tsx index 4a08c91ce06..6668e0f76a9 100644 --- a/app/containers/SearchBox.tsx +++ b/app/containers/SearchBox.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleSheet, Text, View } from 'react-native'; +import { StyleSheet, Text, TextInputProps, View } from 'react-native'; import Touchable from 'react-native-platform-touchable'; import TextInput from '../presentation/TextInput'; @@ -45,7 +45,7 @@ const styles = StyleSheet.create({ }); interface ISearchBox { - onChangeText: () => void; + onChangeText: TextInputProps['onChangeText']; onSubmitEditing: () => void; hasCancel: boolean; onCancelPress: Function; diff --git a/app/definition/IAttachment.ts b/app/definition/IAttachment.ts new file mode 100644 index 00000000000..3d759343556 --- /dev/null +++ b/app/definition/IAttachment.ts @@ -0,0 +1,8 @@ +export interface IAttachment { + title: string; + title_link?: string; + image_url?: string; + image_type?: string; + video_url?: string; + video_type?: string; +} diff --git a/app/definition/IMessage.ts b/app/definition/IMessage.ts new file mode 100644 index 00000000000..aca651c1018 --- /dev/null +++ b/app/definition/IMessage.ts @@ -0,0 +1,3 @@ +export interface IMessage { + msg: string; +} diff --git a/app/definition/IRocketChatRecord.ts b/app/definition/IRocketChatRecord.ts index 0dc3f5f5116..48d91fa84e6 100644 --- a/app/definition/IRocketChatRecord.ts +++ b/app/definition/IRocketChatRecord.ts @@ -1,4 +1,4 @@ export interface IRocketChatRecord { - _id: string; - _updatedAt: Date; + id: string; + updatedAt: Date; } diff --git a/app/definition/IRoom.ts b/app/definition/IRoom.ts index 994835dc322..f36dc05eaec 100644 --- a/app/definition/IRoom.ts +++ b/app/definition/IRoom.ts @@ -19,4 +19,8 @@ export interface IRoom extends IRocketChatRecord { teamId?: string; encrypted?: boolean; visitor?: boolean; + autoTranslateLanguage?: boolean; + autoTranslate?: boolean; + observe?: Function; + usedCannedResponse: string; } diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 4fd9a6faee0..832914b8854 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -1,3 +1,7 @@ +import { TextInputProps } from 'react-native'; + +import { IAttachment } from '../definition/IAttachment'; +import { IMessage } from '../definition/IMessage'; import { IRoom, RoomType } from '../definition/IRoom'; export type ChatsStackParamList = { @@ -69,48 +73,103 @@ export type ChatsStackParamList = { t: RoomType; name: string; }; - AutoTranslateView: {}; - DirectoryView: {}; - NotificationPrefView: {}; - VisitorNavigationView: {}; - ForwardLivechatView: {}; - LivechatEditView: {}; - PickerView: {}; - ThreadMessagesView: {}; - TeamChannelsView: {}; - CreateChannelView: {}; - AddChannelTeamView: {}; - AddExistingChannelView: {}; - MarkdownTableView: {}; - ReadReceiptsView: {}; - QueueListView: {}; - CannedResponsesListView: {}; - CannedResponseDetail: {}; + AutoTranslateView: { + rid: string; + room: IRoom; + }; + DirectoryView: undefined; + NotificationPrefView: { + rid: string; + room: IRoom; + }; + VisitorNavigationView: { + rid: string; + }; + ForwardLivechatView: { + rid: string; + }; + LivechatEditView: { + room: IRoom; + roomUser: any; // change + }; + PickerView: { + title: string; + data: []; // change + value: any; // change + onChangeText: TextInputProps['onChangeText']; + goBack: Function; + onChangeValue: Function; + }; + ThreadMessagesView: { + rid: string; + t: RoomType; + }; + TeamChannelsView: { + teamId: string; + }; + CreateChannelView: { + isTeam?: boolean; // to check + teamId?: string; + }; + AddChannelTeamView: { + teamId?: string; + teamChannels: []; // change + }; + AddExistingChannelView: { + teamId?: boolean; + }; + MarkdownTableView: { + renderRows: Function; + tableWidth: number; + }; + ReadReceiptsView: { + messageId: string; + }; + QueueListView: undefined; + CannedResponsesListView: { + rid: string; + }; + CannedResponseDetail: { + cannedResponse: { + shortcut: string; + text: string; + scopeName: string; + tags: string[]; + }; + room: IRoom; + }; }; export type ProfileStackParamList = { - ProfileView: {}; - UserPreferencesView: {}; - UserNotificationPrefView: {}; - PickerView: {}; + ProfileView: undefined; + UserPreferencesView: undefined; + UserNotificationPrefView: undefined; + PickerView: { + title: string; + data: []; // change + value: any; // change + onChangeText: TextInputProps['onChangeText']; + goBack: Function; + onChangeValue: Function; + }; }; export type SettingsStackParamList = { - SettingsView: {}; - SecurityPrivacyView: {}; - E2EEncryptionSecurityView: {}; - LanguageView: {}; - ThemeView: {}; - DefaultBrowserView: {}; - ScreenLockConfigView: {}; + SettingsView: undefined; + SecurityPrivacyView: undefined; + E2EEncryptionSecurityView: undefined; + LanguageView: undefined; + ThemeView: undefined; + DefaultBrowserView: undefined; + ScreenLockConfigView: undefined; }; export type AdminPanelStackParamList = { - AdminPanelView: {}; + AdminPanelView: undefined; }; export type DisplayPrefStackParamList = { - DisplayPrefsView: {}; + DisplayPrefsView: undefined; }; export type DrawerParamList = { @@ -122,19 +181,34 @@ export type DrawerParamList = { }; export type NewMessageStackParamList = { - NewMessageView: {}; - SelectedUsersViewCreateChannel: {}; // to change - CreateChannelView: {}; - CreateDiscussionView: {}; + NewMessageView: undefined; + SelectedUsersViewCreateChannel: { + maxUsers: number; + showButton: boolean; + title: string; + buttonText: string; + nextAction: Function; + }; // to change + CreateChannelView: { + isTeam?: boolean; // to check + teamId?: string; + }; + CreateDiscussionView: { + channel: IRoom; + message: IMessage; + showCloseModal: boolean; + }; }; export type E2ESaveYourPasswordStackParamList = { - E2ESaveYourPasswordView: {}; - E2EHowItWorksView: {}; + E2ESaveYourPasswordView: undefined; + E2EHowItWorksView: { + showCloseModal: boolean; + }; }; export type E2EEnterYourPasswordStackParamList = { - E2EEnterYourPasswordView: {}; + E2EEnterYourPasswordView: undefined; }; export type InsideStackParamList = { @@ -142,9 +216,24 @@ export type InsideStackParamList = { NewMessageStackNavigator: NewMessageStackParamList; E2ESaveYourPasswordStackNavigator: E2ESaveYourPasswordStackParamList; E2EEnterYourPasswordStackNavigator: E2EEnterYourPasswordStackParamList; - AttachmentView: {}; - StatusView: {}; - ShareView: {}; - ModalBlockView: {}; - JitsiMeetView: {}; + AttachmentView: { + attachment: IAttachment; + }; + StatusView: undefined; + ShareView: { + attachments: IAttachment[]; + isShareView?: boolean; + serverInfo: {}; + text: string; + room: IRoom; + thread: any; // change + }; + ModalBlockView: { + data: any; // change; + }; + JitsiMeetView: { + rid: string; + url: string; + onlyAudio?: boolean; + }; }; diff --git a/app/views/AdminPanelView/index.tsx b/app/views/AdminPanelView/index.tsx index 80f728e1276..f0af5dfa02f 100644 --- a/app/views/AdminPanelView/index.tsx +++ b/app/views/AdminPanelView/index.tsx @@ -9,6 +9,7 @@ import * as HeaderButton from '../../containers/HeaderButton'; import { withTheme } from '../../theme'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; +import { AdminPanelStackParamList } from '../../stacks/types'; interface IAdminPanelViewProps { baseUrl: string; @@ -16,7 +17,7 @@ interface IAdminPanelViewProps { } interface INavigationOptions { - navigation: DrawerScreenProps; + navigation: DrawerScreenProps; isMasterDetail: boolean; } diff --git a/app/views/AutoTranslateView/index.tsx b/app/views/AutoTranslateView/index.tsx index 92a77543a5a..127be2734b9 100644 --- a/app/views/AutoTranslateView/index.tsx +++ b/app/views/AutoTranslateView/index.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { FlatList, StyleSheet, Switch } from 'react-native'; +import { RouteProp } from '@react-navigation/core'; +import { ChatsStackParamList } from '../../stacks/types'; import RocketChat from '../../lib/rocketchat'; import I18n from '../../i18n'; import StatusBar from '../../containers/StatusBar'; @@ -9,6 +11,7 @@ import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; import { withTheme } from '../../theme'; import SafeAreaView from '../../containers/SafeAreaView'; import { events, logEvent } from '../../utils/log'; +import { IRoom } from '../../definition/IRoom'; const styles = StyleSheet.create({ list: { @@ -16,19 +19,8 @@ const styles = StyleSheet.create({ } }); -interface IRoom { - observe: Function; - autoTranslateLanguage: boolean; - autoTranslate: boolean; -} - interface IAutoTranslateViewProps { - route: { - params: { - rid?: string; - room?: IRoom; - }; - }; + route: RouteProp; theme: string; } diff --git a/app/views/CreateDiscussionView/index.tsx b/app/views/CreateDiscussionView/index.tsx index 98b461f0adc..f6055dd1c3a 100644 --- a/app/views/CreateDiscussionView/index.tsx +++ b/app/views/CreateDiscussionView/index.tsx @@ -82,11 +82,12 @@ class CreateChannelView extends React.Component { navigation.setOptions({ title: I18n.t('Create_Discussion'), headerRight: this.valid() - ? () => ( - - - - ) + ? () => + ( + + + + ) as React.ReactNode : null, headerLeft: showCloseModal ? () => : undefined }); diff --git a/app/views/CreateDiscussionView/interfaces.ts b/app/views/CreateDiscussionView/interfaces.ts index 46883311962..e9d076b16ac 100644 --- a/app/views/CreateDiscussionView/interfaces.ts +++ b/app/views/CreateDiscussionView/interfaces.ts @@ -1,14 +1,11 @@ +import { RouteProp } from '@react-navigation/core'; +import { StackNavigationProp } from '@react-navigation/stack'; + +import { NewMessageStackParamList } from '../../stacks/types'; + export interface ICreateChannelViewProps { - navigation: any; - route: { - params?: { - channel: string; - message: { - msg: string; - }; - showCloseModal: boolean; - }; - }; + navigation: StackNavigationProp; + route: RouteProp; server: string; user: { id: string; diff --git a/app/views/DirectoryView/index.tsx b/app/views/DirectoryView/index.tsx index 25d53b831a4..9197815bd55 100644 --- a/app/views/DirectoryView/index.tsx +++ b/app/views/DirectoryView/index.tsx @@ -1,7 +1,9 @@ import React from 'react'; import { FlatList, Text, View } from 'react-native'; import { connect } from 'react-redux'; +import { StackNavigationProp } from '@react-navigation/stack'; +import { ChatsStackParamList } from '../../stacks/types'; import * as List from '../../containers/List'; import Touch from '../../utils/touch'; import RocketChat from '../../lib/rocketchat'; @@ -24,7 +26,7 @@ import styles from './styles'; import Options from './Options'; interface IDirectoryViewProps { - navigation: object; + navigation: StackNavigationProp; baseUrl: string; isFederationEnabled: boolean; user: { diff --git a/app/views/SettingsView/index.tsx b/app/views/SettingsView/index.tsx index 02c17169b19..4fbfc881c6e 100644 --- a/app/views/SettingsView/index.tsx +++ b/app/views/SettingsView/index.tsx @@ -5,6 +5,7 @@ import FastImage from '@rocket.chat/react-native-fast-image'; import CookieManager from '@react-native-cookies/cookies'; import { StackNavigationProp } from '@react-navigation/stack'; +import { SettingsStackParamList } from '../../stacks/types'; import { logout as logoutAction } from '../../actions/login'; import { selectServerRequest as selectServerRequestAction } from '../../actions/server'; import { themes } from '../../constants/colors'; @@ -29,8 +30,8 @@ import database from '../../lib/database'; import { isFDroidBuild } from '../../constants/environment'; import { getUserSelector } from '../../selectors/login'; -interface IProps { - navigation: StackNavigationProp; +interface ISettingsViewProps { + navigation: StackNavigationProp; server: { version: string; server: string; @@ -46,8 +47,8 @@ interface IProps { appStart: Function; } -class SettingsView extends React.Component { - static navigationOptions = ({ navigation, isMasterDetail }: Partial) => ({ +class SettingsView extends React.Component { + static navigationOptions = ({ navigation, isMasterDetail }: Partial) => ({ headerLeft: () => isMasterDetail ? ( From ee14efabac72cd4c1d647a3cd71f7a93ded421fc Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 10 Nov 2021 11:47:50 -0400 Subject: [PATCH 03/23] Add more global definitions and update MasterDetailStack and OutsideStack --- .../IAttachment.ts | 0 app/{definition => definitions}/IMessage.ts | 0 .../IRocketChatRecord.ts | 0 app/{definition => definitions}/IRoom.ts | 0 app/{definition => definitions}/ITeam.js | 0 app/lib/rocketchat.js | 2 +- .../{ModalContainer.js => ModalContainer.tsx} | 19 ++++---- .../MasterDetailStack/{index.js => index.tsx} | 2 - .../{OutsideStack.js => OutsideStack.tsx} | 12 ++--- app/stacks/types.ts | 44 ++++++++++++++----- app/views/AuthenticationWebView.tsx | 14 ++---- app/views/WorkspaceView/index.tsx | 8 +++- 12 files changed, 59 insertions(+), 42 deletions(-) rename app/{definition => definitions}/IAttachment.ts (100%) rename app/{definition => definitions}/IMessage.ts (100%) rename app/{definition => definitions}/IRocketChatRecord.ts (100%) rename app/{definition => definitions}/IRoom.ts (100%) rename app/{definition => definitions}/ITeam.js (100%) rename app/stacks/MasterDetailStack/{ModalContainer.js => ModalContainer.tsx} (60%) rename app/stacks/MasterDetailStack/{index.js => index.tsx} (99%) rename app/stacks/{OutsideStack.js => OutsideStack.tsx} (85%) diff --git a/app/definition/IAttachment.ts b/app/definitions/IAttachment.ts similarity index 100% rename from app/definition/IAttachment.ts rename to app/definitions/IAttachment.ts diff --git a/app/definition/IMessage.ts b/app/definitions/IMessage.ts similarity index 100% rename from app/definition/IMessage.ts rename to app/definitions/IMessage.ts diff --git a/app/definition/IRocketChatRecord.ts b/app/definitions/IRocketChatRecord.ts similarity index 100% rename from app/definition/IRocketChatRecord.ts rename to app/definitions/IRocketChatRecord.ts diff --git a/app/definition/IRoom.ts b/app/definitions/IRoom.ts similarity index 100% rename from app/definition/IRoom.ts rename to app/definitions/IRoom.ts diff --git a/app/definition/ITeam.js b/app/definitions/ITeam.js similarity index 100% rename from app/definition/ITeam.js rename to app/definitions/ITeam.js diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 2862b1d90fa..0883ed18990 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -24,7 +24,7 @@ import { selectServerFailure } from '../actions/server'; import { useSsl } from '../utils/url'; import EventEmitter from '../utils/events'; import { updatePermission } from '../actions/permissions'; -import { TEAM_TYPE } from '../definition/ITeam'; +import { TEAM_TYPE } from '../definitions/ITeam'; import { updateSettings } from '../actions/settings'; import { compareServerVersion, methods } from './utils'; import reduxStore from './createStore'; diff --git a/app/stacks/MasterDetailStack/ModalContainer.js b/app/stacks/MasterDetailStack/ModalContainer.tsx similarity index 60% rename from app/stacks/MasterDetailStack/ModalContainer.js rename to app/stacks/MasterDetailStack/ModalContainer.tsx index 7be11f8c7e8..aeea3d88cdd 100644 --- a/app/stacks/MasterDetailStack/ModalContainer.js +++ b/app/stacks/MasterDetailStack/ModalContainer.tsx @@ -1,10 +1,17 @@ import React from 'react'; import { StyleSheet, TouchableWithoutFeedback, View } from 'react-native'; -import PropTypes from 'prop-types'; +import { StackNavigationProp } from '@react-navigation/stack'; +import { NavigationContainerProps } from '@react-navigation/core'; import sharedStyles from '../../views/Styles'; import { themes } from '../../constants/colors'; +interface IModalContainer extends NavigationContainerProps { + navigation: StackNavigationProp; + children: React.ReactNode; + theme: string; +} + const styles = StyleSheet.create({ root: { flex: 1, @@ -12,11 +19,11 @@ const styles = StyleSheet.create({ justifyContent: 'center' }, backdrop: { - ...StyleSheet.absoluteFill + ...StyleSheet.absoluteFillObject } }); -export const ModalContainer = ({ navigation, children, theme }) => ( +export const ModalContainer = ({ navigation, children, theme }: IModalContainer): JSX.Element => ( navigation.pop()}> @@ -24,9 +31,3 @@ export const ModalContainer = ({ navigation, children, theme }) => ( {children} ); - -ModalContainer.propTypes = { - navigation: PropTypes.object, - children: PropTypes.element, - theme: PropTypes.string -}; diff --git a/app/stacks/MasterDetailStack/index.js b/app/stacks/MasterDetailStack/index.tsx similarity index 99% rename from app/stacks/MasterDetailStack/index.js rename to app/stacks/MasterDetailStack/index.tsx index 71828a6a244..3ce0946dc0a 100644 --- a/app/stacks/MasterDetailStack/index.js +++ b/app/stacks/MasterDetailStack/index.tsx @@ -6,7 +6,6 @@ import { createDrawerNavigator } from '@react-navigation/drawer'; import { ThemeContext } from '../../theme'; import { FadeFromCenterModal, StackAnimation, defaultHeader, themedHeader } from '../../utils/navigation'; - // Chats Stack import RoomView from '../../views/RoomView'; import RoomsListView from '../../views/RoomsListView'; @@ -46,7 +45,6 @@ import UserPreferencesView from '../../views/UserPreferencesView'; import UserNotificationPrefView from '../../views/UserNotificationPreferencesView'; import SecurityPrivacyView from '../../views/SecurityPrivacyView'; import E2EEncryptionSecurityView from '../../views/E2EEncryptionSecurityView'; - // InsideStackNavigator import AttachmentView from '../../views/AttachmentView'; import ModalBlockView from '../../views/ModalBlockView'; diff --git a/app/stacks/OutsideStack.js b/app/stacks/OutsideStack.tsx similarity index 85% rename from app/stacks/OutsideStack.js rename to app/stacks/OutsideStack.tsx index 392850c3ee8..2334f51a1f9 100644 --- a/app/stacks/OutsideStack.js +++ b/app/stacks/OutsideStack.tsx @@ -1,10 +1,9 @@ import React from 'react'; -import { createStackNavigator } from '@react-navigation/stack'; +import { createStackNavigator, StackNavigationOptions } from '@react-navigation/stack'; import { connect } from 'react-redux'; import { ThemeContext } from '../theme'; import { ModalAnimation, StackAnimation, defaultHeader, themedHeader } from '../utils/navigation'; - // Outside Stack import NewServerView from '../views/NewServerView'; import WorkspaceView from '../views/WorkspaceView'; @@ -14,14 +13,15 @@ import SendEmailConfirmationView from '../views/SendEmailConfirmationView'; import RegisterView from '../views/RegisterView'; import LegalView from '../views/LegalView'; import AuthenticationWebView from '../views/AuthenticationWebView'; +import { OutsideModalParamList, OutsideParamList } from './types'; // Outside -const Outside = createStackNavigator(); +const Outside = createStackNavigator(); const _OutsideStack = () => { const { theme } = React.useContext(ThemeContext); return ( - + @@ -37,14 +37,14 @@ const _OutsideStack = () => { ); }; -const mapStateToProps = state => ({ +const mapStateToProps = (state: any) => ({ root: state.app.root }); const OutsideStack = connect(mapStateToProps)(_OutsideStack); // OutsideStackModal -const OutsideModal = createStackNavigator(); +const OutsideModal = createStackNavigator(); const OutsideStackModal = () => { const { theme } = React.useContext(ThemeContext); diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 832914b8854..c8e3c81f486 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -1,8 +1,9 @@ +import { NavigatorScreenParams } from '@react-navigation/core'; import { TextInputProps } from 'react-native'; -import { IAttachment } from '../definition/IAttachment'; -import { IMessage } from '../definition/IMessage'; -import { IRoom, RoomType } from '../definition/IRoom'; +import { IAttachment } from '../definitions/IAttachment'; +import { IMessage } from '../definitions/IMessage'; +import { IRoom, RoomType } from '../definitions/IRoom'; export type ChatsStackParamList = { RoomsListView: undefined; @@ -173,11 +174,11 @@ export type DisplayPrefStackParamList = { }; export type DrawerParamList = { - ChatsStackNavigator: ChatsStackParamList; - ProfileStackNavigator: ProfileStackParamList; - SettingsStackNavigator: SettingsStackParamList; - AdminPanelStackNavigator: AdminPanelStackParamList; - DisplayPrefStackNavigator: DisplayPrefStackParamList; + ChatsStackNavigator: NavigatorScreenParams; + ProfileStackNavigator: NavigatorScreenParams; + SettingsStackNavigator: NavigatorScreenParams; + AdminPanelStackNavigator: NavigatorScreenParams; + DisplayPrefStackNavigator: NavigatorScreenParams; }; export type NewMessageStackParamList = { @@ -212,10 +213,10 @@ export type E2EEnterYourPasswordStackParamList = { }; export type InsideStackParamList = { - DrawerNavigator: DrawerParamList; - NewMessageStackNavigator: NewMessageStackParamList; - E2ESaveYourPasswordStackNavigator: E2ESaveYourPasswordStackParamList; - E2EEnterYourPasswordStackNavigator: E2EEnterYourPasswordStackParamList; + DrawerNavigator: NavigatorScreenParams; + NewMessageStackNavigator: NavigatorScreenParams; + E2ESaveYourPasswordStackNavigator: NavigatorScreenParams; + E2EEnterYourPasswordStackNavigator: NavigatorScreenParams; AttachmentView: { attachment: IAttachment; }; @@ -237,3 +238,22 @@ export type InsideStackParamList = { onlyAudio?: boolean; }; }; + +export type OutsideParamList = { + NewServerView: undefined; + WorkspaceView: {}; + LoginView: {}; + ForgotPasswordView: {}; + SendEmailConfirmationView: {}; + RegisterView: {}; + LegalView: {}; +}; + +export type OutsideModalParamList = { + OutsideStack: NavigatorScreenParams; + AuthenticationWebView: { + authType: string; + url: string; + ssoToken?: string; + }; +}; diff --git a/app/views/AuthenticationWebView.tsx b/app/views/AuthenticationWebView.tsx index 870af95602e..ac304fbfb5e 100644 --- a/app/views/AuthenticationWebView.tsx +++ b/app/views/AuthenticationWebView.tsx @@ -4,7 +4,9 @@ import { connect } from 'react-redux'; import parse from 'url-parse'; import { StackNavigationProp } from '@react-navigation/stack'; import { WebViewMessage } from 'react-native-webview/lib/WebViewTypes'; +import { RouteProp } from '@react-navigation/core'; +import { OutsideModalParamList } from '../stacks/types'; import RocketChat from '../lib/rocketchat'; import { isIOS } from '../utils/deviceInfo'; import StatusBar from '../containers/StatusBar'; @@ -41,17 +43,9 @@ window.addEventListener('popstate', function() { }); `; -interface IRoute { - params: { - authType: string; - url: string; - ssoToken?: string; - }; -} - interface INavigationOption { - navigation: StackNavigationProp; - route: IRoute; + navigation: StackNavigationProp; + route: RouteProp; } interface IAuthenticationWebView extends INavigationOption { diff --git a/app/views/WorkspaceView/index.tsx b/app/views/WorkspaceView/index.tsx index 68ac5157b42..827d6a44e9d 100644 --- a/app/views/WorkspaceView/index.tsx +++ b/app/views/WorkspaceView/index.tsx @@ -2,7 +2,9 @@ import React from 'react'; import { Text, View } from 'react-native'; import { StackNavigationProp, StackNavigationOptions } from '@react-navigation/stack'; import { connect } from 'react-redux'; +import { CompositeNavigationProp } from '@react-navigation/core'; +import { OutsideModalParamList, OutsideParamList } from '../../stacks/types'; import I18n from '../../i18n'; import Button from '../../containers/Button'; import { themes } from '../../constants/colors'; @@ -13,8 +15,10 @@ import ServerAvatar from './ServerAvatar'; import styles from './styles'; interface IWorkSpaceProp { - // TODO: waiting for the RootStackParamList https://reactnavigation.org/docs/typescript/#type-checking-screens - navigation: StackNavigationProp; + navigation: CompositeNavigationProp< + StackNavigationProp, + StackNavigationProp + >; theme: string; Site_Name: string; Site_Url: string; From e11390c08489b769ed94b01f53d6417ef949f1c9 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Mon, 15 Nov 2021 12:01:44 -0400 Subject: [PATCH 04/23] complete outsidestack param list --- app/stacks/types.ts | 21 +++++++++++++++------ app/views/LoginView.tsx | 15 ++++++++------- app/views/RegisterView.tsx | 3 ++- app/views/SendEmailConfirmationView.tsx | 14 ++++++-------- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/app/stacks/types.ts b/app/stacks/types.ts index c8e3c81f486..dc0a083d222 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -241,12 +241,21 @@ export type InsideStackParamList = { export type OutsideParamList = { NewServerView: undefined; - WorkspaceView: {}; - LoginView: {}; - ForgotPasswordView: {}; - SendEmailConfirmationView: {}; - RegisterView: {}; - LegalView: {}; + WorkspaceView: undefined; + LoginView: { + title: string; + username?: string; + }; + ForgotPasswordView: { + title: string; + }; + SendEmailConfirmationView: { + user?: string; + }; + RegisterView: { + title: string; + }; + LegalView: undefined; }; export type OutsideModalParamList = { diff --git a/app/views/LoginView.tsx b/app/views/LoginView.tsx index 4643687e2fc..ef965a78dc0 100644 --- a/app/views/LoginView.tsx +++ b/app/views/LoginView.tsx @@ -15,6 +15,7 @@ import TextInput from '../containers/TextInput'; import { loginRequest as loginRequestAction } from '../actions/login'; import LoginServices from '../containers/LoginServices'; import sharedStyles from './Styles'; +import { OutsideParamList } from '../stacks/types'; const styles = StyleSheet.create({ registerDisabled: { @@ -47,9 +48,9 @@ const styles = StyleSheet.create({ } }); -interface IProps { - navigation: StackNavigationProp; - route: RouteProp; +interface ILoginViewProps { + navigation: StackNavigationProp; + route: RouteProp; Site_Name: string; Accounts_RegistrationForm: string; Accounts_RegistrationForm_LinkReplacementText: string; @@ -67,15 +68,15 @@ interface IProps { inviteLinkToken: string; } -class LoginView extends React.Component { +class LoginView extends React.Component { private passwordInput: any; - static navigationOptions = ({ route, navigation }: Partial) => ({ + static navigationOptions = ({ route, navigation }: Partial) => ({ title: route?.params?.title ?? 'Rocket.Chat', headerRight: () => }); - constructor(props: IProps) { + constructor(props: ILoginViewProps) { super(props); this.state = { user: props.route.params?.username ?? '', @@ -83,7 +84,7 @@ class LoginView extends React.Component { }; } - UNSAFE_componentWillReceiveProps(nextProps: IProps) { + UNSAFE_componentWillReceiveProps(nextProps: ILoginViewProps) { const { error } = this.props; if (nextProps.failure && !dequal(error, nextProps.error)) { if (nextProps.error?.error === 'error-invalid-email') { diff --git a/app/views/RegisterView.tsx b/app/views/RegisterView.tsx index 04571216311..17b7cf63697 100644 --- a/app/views/RegisterView.tsx +++ b/app/views/RegisterView.tsx @@ -5,6 +5,7 @@ import { RouteProp } from '@react-navigation/core'; import { connect } from 'react-redux'; import RNPickerSelect from 'react-native-picker-select'; +import { OutsideParamList } from '../stacks/types'; import log, { events, logEvent } from '../utils/log'; import Button from '../containers/Button'; import I18n from '../i18n'; @@ -52,7 +53,7 @@ const styles = StyleSheet.create({ interface IProps { navigation: StackNavigationProp; - route: RouteProp; + route: RouteProp; server: string; Site_Name: string; Gitlab_URL: string; diff --git a/app/views/SendEmailConfirmationView.tsx b/app/views/SendEmailConfirmationView.tsx index 892673acc83..a3aad497915 100644 --- a/app/views/SendEmailConfirmationView.tsx +++ b/app/views/SendEmailConfirmationView.tsx @@ -1,6 +1,8 @@ import React, { useEffect, useState } from 'react'; import { StackNavigationProp } from '@react-navigation/stack'; +import { RouteProp } from '@react-navigation/core'; +import { OutsideParamList } from '../stacks/types'; import TextInput from '../containers/TextInput'; import Button from '../containers/Button'; import { showErrorAlert } from '../utils/info'; @@ -12,16 +14,12 @@ import FormContainer, { FormContainerInner } from '../containers/FormContainer'; import log, { events, logEvent } from '../utils/log'; import sharedStyles from './Styles'; -interface ISendEmailConfirmationView { - navigation: StackNavigationProp; - route: { - params: { - user?: string; - }; - }; +interface ISendEmailConfirmationViewProps { + navigation: StackNavigationProp; + route: RouteProp; } -const SendEmailConfirmationView = ({ navigation, route }: ISendEmailConfirmationView): JSX.Element => { +const SendEmailConfirmationView = ({ navigation, route }: ISendEmailConfirmationViewProps): JSX.Element => { const [email, setEmail] = useState(''); const [invalidEmail, setInvalidEmail] = useState(true); const [isFetching, setIsFetching] = useState(false); From 5dbac8cf1632ae24aaf7036f3319273cbb233149 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Mon, 15 Nov 2021 22:12:40 -0400 Subject: [PATCH 05/23] add masterdetailstack types --- app/stacks/MasterDetailStack/index.tsx | 32 +++-- app/stacks/MasterDetailStack/types.ts | 191 +++++++++++++++++++++++++ 2 files changed, 209 insertions(+), 14 deletions(-) create mode 100644 app/stacks/MasterDetailStack/types.ts diff --git a/app/stacks/MasterDetailStack/index.tsx b/app/stacks/MasterDetailStack/index.tsx index 3ce0946dc0a..61dc33a2efa 100644 --- a/app/stacks/MasterDetailStack/index.tsx +++ b/app/stacks/MasterDetailStack/index.tsx @@ -1,7 +1,6 @@ import React, { useEffect } from 'react'; -import PropTypes from 'prop-types'; import { useIsFocused } from '@react-navigation/native'; -import { createStackNavigator } from '@react-navigation/stack'; +import { createStackNavigator, StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; import { createDrawerNavigator } from '@react-navigation/drawer'; import { ThemeContext } from '../../theme'; @@ -61,9 +60,10 @@ import AddChannelTeamView from '../../views/AddChannelTeamView'; import AddExistingChannelView from '../../views/AddExistingChannelView'; import SelectListView from '../../views/SelectListView'; import { ModalContainer } from './ModalContainer'; +import { ChatsStackParamList, DrawerParamList, InsideStackParamList, ModalStackParamList } from './types'; // ChatsStackNavigator -const ChatsStack = createStackNavigator(); +const ChatsStack = createStackNavigator(); const ChatsStackNavigator = React.memo(() => { const { theme } = React.useContext(ThemeContext); @@ -80,14 +80,15 @@ const ChatsStackNavigator = React.memo(() => { }, [isFocused]); return ( - + ); }); // DrawerNavigator -const Drawer = createDrawerNavigator(); +const Drawer = createDrawerNavigator(); const DrawerNavigator = React.memo(() => ( } @@ -96,12 +97,17 @@ const DrawerNavigator = React.memo(() => ( )); -const ModalStack = createStackNavigator(); -const ModalStackNavigator = React.memo(({ navigation }) => { +export interface INavigation { + navigation: StackNavigationProp; +} + +const ModalStack = createStackNavigator(); +const ModalStackNavigator = React.memo(({ navigation }: INavigation) => { const { theme } = React.useContext(ThemeContext); return ( - + { ); }); -ModalStackNavigator.propTypes = { - navigation: PropTypes.object -}; - // InsideStackNavigator -const InsideStack = createStackNavigator(); +const InsideStack = createStackNavigator(); const InsideStackNavigator = React.memo(() => { const { theme } = React.useContext(ThemeContext); return ( - + diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts new file mode 100644 index 00000000000..4aba2542503 --- /dev/null +++ b/app/stacks/MasterDetailStack/types.ts @@ -0,0 +1,191 @@ +import { TextInputProps } from 'react-native'; +import { NavigatorScreenParams } from '@react-navigation/core'; + +import { IAttachment } from '../../definitions/IAttachment'; +import { IMessage } from '../../definitions/IMessage'; +import { IRoom, RoomType } from '../../definitions/IRoom'; + +export type ChatsStackParamList = { + RoomView: undefined; +}; + +export type DrawerParamList = { + ChatsStackNavigator: NavigatorScreenParams; +}; + +export type ModalStackParamList = { + RoomActionsView: { + room: IRoom; + member: any; + rid: string; + t: RoomType; + joined: boolean; + }; + RoomInfoView: { + room: IRoom; + member: any; + rid: string; + t: RoomType; + }; + SelectListView: { + data: any; + title: string; + infoText: string; + nextAction: Function; + showAlert: boolean; + isSearch: boolean; + onSearch: Function; + isRadio?: boolean; + }; + RoomInfoEditView: { + rid: string; + }; + RoomMembersView: { + rid: string; + room: IRoom; + }; + SearchMessagesView: { + rid: string; + t: RoomType; + encrypted?: boolean; + showCloseModal?: boolean; + }; + SelectedUsersView: { + maxUsers: number; + showButton: boolean; + title: string; + buttonText: string; + nextAction: Function; + }; + InviteUsersView: { + rid: string; + }; + AddChannelTeamView: { + teamId?: string; + teamChannels: []; // change + }; + AddExistingChannelView: { + teamId?: boolean; + }; + InviteUsersEditView: { + rid: string; + }; + MessagesView: { + rid: string; + t: RoomType; + name: string; + }; + AutoTranslateView: { + rid: string; + room: IRoom; + }; + DirectoryView: undefined; + QueueListView: undefined; + NotificationPrefView: { + rid: string; + room: IRoom; + }; + VisitorNavigationView: { + rid: string; + }; + ForwardLivechatView: { + rid: string; + }; + CannedResponsesListView: { + rid: string; + }; + CannedResponseDetail: { + cannedResponse: { + shortcut: string; + text: string; + scopeName: string; + tags: string[]; + }; + room: IRoom; + }; + LivechatEditView: { + room: IRoom; + roomUser: any; // change + }; + PickerView: { + title: string; + data: []; // change + value: any; // change + onChangeText: TextInputProps['onChangeText']; + goBack: Function; + onChangeValue: Function; + }; + ThreadMessagesView: { + rid: string; + t: RoomType; + }; + TeamChannelsView: { + teamId: string; + }; + MarkdownTableView: { + renderRows: Function; + tableWidth: number; + }; + ReadReceiptsView: { + messageId: string; + }; + SettingsView: undefined; + LanguageView: undefined; + ThemeView: undefined; + DefaultBrowserView: undefined; + ScreenLockConfigView: undefined; + StatusView: undefined; + ProfileView: undefined; + DisplayPrefsView: undefined; + AdminPanelView: undefined; + NewMessageView: undefined; + SelectedUsersViewCreateChannel: { + maxUsers: number; + showButton: boolean; + title: string; + buttonText: string; + nextAction: Function; + }; // to change + CreateChannelView: { + isTeam?: boolean; // to check + teamId?: string; + }; + CreateDiscussionView: { + channel: IRoom; + message: IMessage; + showCloseModal: boolean; + }; + E2ESaveYourPasswordView: undefined; + E2EHowItWorksView: { + showCloseModal: boolean; + }; + E2EEnterYourPasswordView: undefined; + UserPreferencesView: undefined; + UserNotificationPrefView: undefined; + SecurityPrivacyView: undefined; + E2EEncryptionSecurityView: undefined; +}; + +export type InsideStackParamList = { + DrawerNavigator: NavigatorScreenParams; + ModalStackNavigator: NavigatorScreenParams; + AttachmentView: { + attachment: IAttachment; + }; + ModalBlockView: { + data: any; // change; + }; + JitsiMeetView: { + rid: string; + url: string; + onlyAudio?: boolean; + }; + ShareView: { + attachments: IAttachment[]; + isShareView?: boolean; + serverInfo: {}; + text: string; + room: IRoom; + thread: any; // change + }; +}; From 3546d1d586fb1c19ca1767a6c3b08e5e9764f781 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 17 Nov 2021 17:03:18 -0400 Subject: [PATCH 06/23] update views interfaces, create IServer.ts --- app/definitions/IAttachment.ts | 2 +- app/definitions/IServer.ts | 16 +++++++++++ app/stacks/MasterDetailStack/index.tsx | 6 ++--- app/stacks/MasterDetailStack/types.ts | 8 +++--- app/stacks/types.ts | 4 ++- app/views/AutoTranslateView/index.tsx | 2 +- app/views/MessagesView/index.tsx | 13 +++------ app/views/ProfileView/interfaces.ts | 6 ++--- app/views/SearchMessagesView/index.tsx | 36 ++++++++++++++----------- app/views/ShareView/index.tsx | 27 +++++-------------- app/views/ShareView/interfaces.ts | 18 ------------- app/views/UserPreferencesView/index.tsx | 5 ++-- 12 files changed, 65 insertions(+), 78 deletions(-) create mode 100644 app/definitions/IServer.ts diff --git a/app/definitions/IAttachment.ts b/app/definitions/IAttachment.ts index 3d759343556..dc0e6f9ee74 100644 --- a/app/definitions/IAttachment.ts +++ b/app/definitions/IAttachment.ts @@ -1,5 +1,5 @@ export interface IAttachment { - title: string; + title?: string; title_link?: string; image_url?: string; image_type?: string; diff --git a/app/definitions/IServer.ts b/app/definitions/IServer.ts new file mode 100644 index 00000000000..534a29c9ce2 --- /dev/null +++ b/app/definitions/IServer.ts @@ -0,0 +1,16 @@ +export interface IServer { + name: string; + iconURL: string; + useRealName: boolean; + FileUpload_MediaTypeWhiteList: string; + FileUpload_MaxFileSize: number; + roomsUpdatedAt: Date; + version: string; + lastLocalAuthenticatedSession: Date; + autoLock: boolean; + autoLockTime: number | null; + biometry: boolean | null; + uniqueID: string; + enterpriseModules: string; + E2E_Enable: boolean; +} diff --git a/app/stacks/MasterDetailStack/index.tsx b/app/stacks/MasterDetailStack/index.tsx index 61dc33a2efa..e260ece8687 100644 --- a/app/stacks/MasterDetailStack/index.tsx +++ b/app/stacks/MasterDetailStack/index.tsx @@ -60,10 +60,10 @@ import AddChannelTeamView from '../../views/AddChannelTeamView'; import AddExistingChannelView from '../../views/AddExistingChannelView'; import SelectListView from '../../views/SelectListView'; import { ModalContainer } from './ModalContainer'; -import { ChatsStackParamList, DrawerParamList, InsideStackParamList, ModalStackParamList } from './types'; +import { MasterDetailChatsStackParamList, MasterDetailDrawerParamList, InsideStackParamList, ModalStackParamList } from './types'; // ChatsStackNavigator -const ChatsStack = createStackNavigator(); +const ChatsStack = createStackNavigator(); const ChatsStackNavigator = React.memo(() => { const { theme } = React.useContext(ThemeContext); @@ -88,7 +88,7 @@ const ChatsStackNavigator = React.memo(() => { }); // DrawerNavigator -const Drawer = createDrawerNavigator(); +const Drawer = createDrawerNavigator(); const DrawerNavigator = React.memo(() => ( } diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index 4aba2542503..a3dda97cdb2 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -5,12 +5,12 @@ import { IAttachment } from '../../definitions/IAttachment'; import { IMessage } from '../../definitions/IMessage'; import { IRoom, RoomType } from '../../definitions/IRoom'; -export type ChatsStackParamList = { +export type MasterDetailChatsStackParamList = { RoomView: undefined; }; -export type DrawerParamList = { - ChatsStackNavigator: NavigatorScreenParams; +export type MasterDetailDrawerParamList = { + ChatsStackNavigator: NavigatorScreenParams; }; export type ModalStackParamList = { @@ -167,7 +167,7 @@ export type ModalStackParamList = { }; export type InsideStackParamList = { - DrawerNavigator: NavigatorScreenParams; + DrawerNavigator: NavigatorScreenParams; ModalStackNavigator: NavigatorScreenParams; AttachmentView: { attachment: IAttachment; diff --git a/app/stacks/types.ts b/app/stacks/types.ts index dc0a083d222..63dca5c620f 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -1,6 +1,7 @@ import { NavigatorScreenParams } from '@react-navigation/core'; import { TextInputProps } from 'react-native'; +import { IServer } from '../definitions/IServer'; import { IAttachment } from '../definitions/IAttachment'; import { IMessage } from '../definitions/IMessage'; import { IRoom, RoomType } from '../definitions/IRoom'; @@ -224,7 +225,8 @@ export type InsideStackParamList = { ShareView: { attachments: IAttachment[]; isShareView?: boolean; - serverInfo: {}; + isShareExtension: boolean; + serverInfo: IServer; text: string; room: IRoom; thread: any; // change diff --git a/app/views/AutoTranslateView/index.tsx b/app/views/AutoTranslateView/index.tsx index 127be2734b9..f840ca12a5e 100644 --- a/app/views/AutoTranslateView/index.tsx +++ b/app/views/AutoTranslateView/index.tsx @@ -11,7 +11,7 @@ import { SWITCH_TRACK_COLOR, themes } from '../../constants/colors'; import { withTheme } from '../../theme'; import SafeAreaView from '../../containers/SafeAreaView'; import { events, logEvent } from '../../utils/log'; -import { IRoom } from '../../definition/IRoom'; +import { IRoom } from '../../definitions/IRoom'; const styles = StyleSheet.create({ list: { diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index a948edcd181..ef93017230d 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -18,22 +18,15 @@ import { withActionSheet } from '../../containers/ActionSheet'; import SafeAreaView from '../../containers/SafeAreaView'; import getThreadName from '../../lib/methods/getThreadName'; import styles from './styles'; - -type TMessagesViewRouteParams = { - MessagesView: { - rid: string; - t: string; - name: string; - }; -}; +import { ChatsStackParamList } from '../../stacks/types'; interface IMessagesViewProps { user: { id: string; }; baseUrl: string; - navigation: StackNavigationProp; - route: RouteProp; + navigation: StackNavigationProp; + route: RouteProp; customEmojis: { [key: string]: string }; theme: string; showActionSheet: Function; diff --git a/app/views/ProfileView/interfaces.ts b/app/views/ProfileView/interfaces.ts index 00117203e5a..bfec50c0dd3 100644 --- a/app/views/ProfileView/interfaces.ts +++ b/app/views/ProfileView/interfaces.ts @@ -1,6 +1,8 @@ import { StackNavigationProp } from '@react-navigation/stack'; import React from 'react'; +import { ProfileStackParamList } from '../../stacks/types'; + export interface IUser { id: string; name: string; @@ -31,14 +33,12 @@ export interface IAvatarButton { } export interface INavigationOptions { - navigation: StackNavigationProp; + navigation: StackNavigationProp; isMasterDetail?: boolean; } export interface IProfileViewProps { user: IUser; - navigation: StackNavigationProp; - isMasterDetail?: boolean; baseUrl: string; Accounts_AllowEmailChange: boolean; Accounts_AllowPasswordChange: boolean; diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index a9be999187a..a85df674590 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -1,11 +1,13 @@ import React from 'react'; import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; -import { RouteProp } from '@react-navigation/core'; +import { CompositeNavigationProp, RouteProp } from '@react-navigation/core'; import { FlatList, Text, View } from 'react-native'; import { Q } from '@nozbe/watermelondb'; import { connect } from 'react-redux'; import { dequal } from 'dequal'; +import { IRoom, RoomType } from '../../definitions/IRoom'; +import { IAttachment } from '../../definitions/IAttachment'; import RCTextInput from '../../containers/TextInput'; import ActivityIndicator from '../../containers/ActivityIndicator'; import Markdown from '../../containers/markdown'; @@ -13,7 +15,7 @@ import debounce from '../../utils/debounce'; import RocketChat from '../../lib/rocketchat'; import Message from '../../containers/message'; import scrollPersistTaps from '../../utils/scrollPersistTaps'; -import { IMessage, IMessageAttachments } from '../../containers/message/interfaces'; +import { IMessage } from '../../containers/message/interfaces'; import I18n from '../../i18n'; import StatusBar from '../../containers/StatusBar'; import log from '../../utils/log'; @@ -29,26 +31,30 @@ import getRoomInfo from '../../lib/methods/getRoomInfo'; import { isIOS } from '../../utils/deviceInfo'; import { compareServerVersion, methods } from '../../lib/utils'; import styles from './styles'; +import { InsideStackParamList, ChatsStackParamList } from '../../stacks/types'; const QUERY_SIZE = 50; -type TRouteParams = { - SearchMessagesView: { - showCloseModal?: boolean; - rid: string; - t?: string; - encrypted?: boolean; - }; -}; - interface ISearchMessagesViewState { loading: boolean; messages: IMessage[]; searchText: string; } + +interface IRoomInfoParam { + room: IRoom; + member: any; + rid: string; + t: RoomType; + joined: boolean; +} + interface INavigationOption { - navigation: StackNavigationProp; - route: RouteProp; + navigation: CompositeNavigationProp< + StackNavigationProp, + StackNavigationProp + >; + route: RouteProp; } interface ISearchMessagesViewProps extends INavigationOption { @@ -183,12 +189,12 @@ class SearchMessagesView extends React.Component { + showAttachment = (attachment: IAttachment) => { const { navigation } = this.props; navigation.navigate('AttachmentView', { attachment }); }; - navToRoomInfo = (navParam: IMessage) => { + navToRoomInfo = (navParam: IRoomInfoParam) => { const { navigation, user } = this.props; if (navParam.rid === user.id) { return; diff --git a/app/views/ShareView/index.tsx b/app/views/ShareView/index.tsx index e10b21483b2..4061626e69a 100644 --- a/app/views/ShareView/index.tsx +++ b/app/views/ShareView/index.tsx @@ -5,6 +5,7 @@ import { NativeModules, Text, View } from 'react-native'; import { connect } from 'react-redux'; import ShareExtension from 'rn-extensions-share'; +import { InsideStackParamList } from '../../stacks/types'; import { themes } from '../../constants/colors'; import I18n from '../../i18n'; import Loading from '../../containers/Loading'; @@ -25,7 +26,8 @@ import Thumbs from './Thumbs'; import Preview from './Preview'; import Header from './Header'; import styles from './styles'; -import { IAttachment, IServer } from './interfaces'; +import { IAttachment } from './interfaces'; +import { IRoom } from '../../definitions/IRoom'; interface IShareViewState { selected: IAttachment; @@ -33,30 +35,15 @@ interface IShareViewState { readOnly: boolean; attachments: IAttachment[]; text: string; - // TODO: Refactor when migrate room - room: any; - thread: any; + room: IRoom; + thread: any; // change maxFileSize: number; mediaAllowList: number; } interface IShareViewProps { - // TODO: Refactor after react-navigation - navigation: StackNavigationProp; - route: RouteProp< - { - ShareView: { - attachments: IAttachment[]; - isShareView?: boolean; - isShareExtension: boolean; - serverInfo: IServer; - text: string; - room: any; - thread: any; // change - }; - }, - 'ShareView' - >; + navigation: StackNavigationProp; + route: RouteProp; theme: string; user: { id: string; diff --git a/app/views/ShareView/interfaces.ts b/app/views/ShareView/interfaces.ts index 09cb4d9eb53..a2231450d52 100644 --- a/app/views/ShareView/interfaces.ts +++ b/app/views/ShareView/interfaces.ts @@ -13,21 +13,3 @@ export interface IUseDimensions { width: number; height: number; } - -// TODO: move this to specific folder -export interface IServer { - name: string; - iconURL: string; - useRealName: boolean; - FileUpload_MediaTypeWhiteList: string; - FileUpload_MaxFileSize: number; - roomsUpdatedAt: Date; - version: string; - lastLocalAuthenticatedSession: Date; - autoLock: boolean; - autoLockTime: number | null; - biometry: boolean | null; - uniqueID: string; - enterpriseModules: string; - E2E_Enable: boolean; -} diff --git a/app/views/UserPreferencesView/index.tsx b/app/views/UserPreferencesView/index.tsx index 2abce444e32..59f0f9f3ae7 100644 --- a/app/views/UserPreferencesView/index.tsx +++ b/app/views/UserPreferencesView/index.tsx @@ -11,9 +11,10 @@ import * as List from '../../containers/List'; import { SWITCH_TRACK_COLOR } from '../../constants/colors'; import { getUserSelector } from '../../selectors/login'; import RocketChat from '../../lib/rocketchat'; +import { ProfileStackParamList } from '../../stacks/types'; interface IUserPreferencesViewProps { - navigation: StackNavigationProp; + navigation: StackNavigationProp; } const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Element => { @@ -26,7 +27,7 @@ const UserPreferencesView = ({ navigation }: IUserPreferencesViewProps): JSX.Ele }); }, []); - const navigateToScreen = (screen: string) => { + const navigateToScreen = (screen: keyof ProfileStackParamList) => { logEvent(events.UP_GO_USER_NOTIFICATION_PREF); navigation.navigate(screen); }; From e3970416a0680c65e8a262f7e82026fc688a37ce Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Thu, 18 Nov 2021 17:54:28 -0400 Subject: [PATCH 07/23] update interfaces and types --- app/stacks/MasterDetailStack/index.tsx | 9 +++++++-- app/stacks/MasterDetailStack/types.ts | 16 ++++++++++++++-- app/stacks/types.ts | 2 +- app/views/MessagesView/index.tsx | 19 ++++++++++++++++--- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/app/stacks/MasterDetailStack/index.tsx b/app/stacks/MasterDetailStack/index.tsx index e260ece8687..5679561db4c 100644 --- a/app/stacks/MasterDetailStack/index.tsx +++ b/app/stacks/MasterDetailStack/index.tsx @@ -60,7 +60,12 @@ import AddChannelTeamView from '../../views/AddChannelTeamView'; import AddExistingChannelView from '../../views/AddExistingChannelView'; import SelectListView from '../../views/SelectListView'; import { ModalContainer } from './ModalContainer'; -import { MasterDetailChatsStackParamList, MasterDetailDrawerParamList, InsideStackParamList, ModalStackParamList } from './types'; +import { + MasterDetailChatsStackParamList, + MasterDetailDrawerParamList, + MasterDetailInsideStackParamList, + ModalStackParamList +} from './types'; // ChatsStackNavigator const ChatsStack = createStackNavigator(); @@ -256,7 +261,7 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => { }); // InsideStackNavigator -const InsideStack = createStackNavigator(); +const InsideStack = createStackNavigator(); const InsideStackNavigator = React.memo(() => { const { theme } = React.useContext(ThemeContext); return ( diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index a3dda97cdb2..4c08f822c08 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -6,7 +6,19 @@ import { IMessage } from '../../definitions/IMessage'; import { IRoom, RoomType } from '../../definitions/IRoom'; export type MasterDetailChatsStackParamList = { - RoomView: undefined; + RoomView: { + rid: string; + t: RoomType; + tmid?: string; + message?: string; + name: string; + fname: string; + prid?: string; + room: IRoom; + jumpToMessageId?: string; + jumpToThreadId?: string; + roomUserId: string; + }; }; export type MasterDetailDrawerParamList = { @@ -166,7 +178,7 @@ export type ModalStackParamList = { E2EEncryptionSecurityView: undefined; }; -export type InsideStackParamList = { +export type MasterDetailInsideStackParamList = { DrawerNavigator: NavigatorScreenParams; ModalStackNavigator: NavigatorScreenParams; AttachmentView: { diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 63dca5c620f..0ae6de80825 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -13,7 +13,7 @@ export type ChatsStackParamList = { t: RoomType; tmid?: string; message?: string; - name: string; + name?: string; fname: string; prid?: string; room: IRoom; diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index ef93017230d..5f0fa136c06 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -3,8 +3,9 @@ import { FlatList, Text, View } from 'react-native'; import { connect } from 'react-redux'; import { dequal } from 'dequal'; import { StackNavigationProp } from '@react-navigation/stack'; -import { RouteProp } from '@react-navigation/core'; +import { CompositeNavigationProp, RouteProp } from '@react-navigation/core'; +import { MasterDetailInsideStackParamList, ModalStackParamList } from '../../stacks/MasterDetailStack/types'; import Message from '../../containers/message'; import ActivityIndicator from '../../containers/ActivityIndicator'; import I18n from '../../i18n'; @@ -19,13 +20,17 @@ import SafeAreaView from '../../containers/SafeAreaView'; import getThreadName from '../../lib/methods/getThreadName'; import styles from './styles'; import { ChatsStackParamList } from '../../stacks/types'; +import { IRoom, RoomType } from '../../definitions/IRoom'; interface IMessagesViewProps { user: { id: string; }; baseUrl: string; - navigation: StackNavigationProp; + navigation: CompositeNavigationProp< + StackNavigationProp, + CompositeNavigationProp, StackNavigationProp> + >; route: RouteProp; customEmojis: { [key: string]: string }; theme: string; @@ -34,6 +39,14 @@ interface IMessagesViewProps { isMasterDetail: boolean; } +interface IRoomInfoParam { + room: IRoom; + member: any; + rid: string; + t: RoomType; + joined: boolean; +} + interface IMessagesViewState { loading: boolean; messages: []; @@ -114,7 +127,7 @@ class MessagesView extends React.Component { }); }; - navToRoomInfo = (navParam: { rid: string }) => { + navToRoomInfo = (navParam: IRoomInfoParam) => { const { navigation, user } = this.props; if (navParam.rid === user.id) { return; From d0d918a0bf92698a64062746ab62c8c0988081f5 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Mon, 22 Nov 2021 18:19:58 -0400 Subject: [PATCH 08/23] update screens interfaces --- app/definitions/IAttachment.ts | 2 +- app/definitions/IRoom.ts | 3 +- app/stacks/MasterDetailStack/types.ts | 8 +-- app/stacks/types.ts | 63 ++++++++++--------- app/views/AddChannelTeamView.tsx | 21 +++++-- app/views/AddExistingChannelView.tsx | 7 ++- app/views/AttachmentView.tsx | 16 ++--- app/views/CreateChannelView.tsx | 9 +-- app/views/E2EEnterYourPasswordView.tsx | 3 +- app/views/E2EHowItWorksView.tsx | 5 +- app/views/E2ESaveYourPasswordView.tsx | 3 +- app/views/ForgotPasswordView.tsx | 5 +- app/views/ForwardLivechatView.tsx | 11 ++-- app/views/InviteUsersEditView/index.tsx | 5 +- app/views/JitsiMeetView.tsx | 5 +- app/views/MarkdownTableView.tsx | 6 +- app/views/MessagesView/index.tsx | 23 ++++--- app/views/NewServerView/index.tsx | 3 +- .../NotificationPreferencesView/index.tsx | 13 +--- .../NotificationPreferencesView/options.ts | 2 +- app/views/PickerView.tsx | 32 +++------- app/views/ReadReceiptView/index.tsx | 5 +- app/views/RegisterView.tsx | 2 +- app/views/SidebarView/index.tsx | 5 +- .../UserNotificationPreferencesView/index.tsx | 3 +- app/views/WithoutServersView.tsx | 6 +- 26 files changed, 134 insertions(+), 132 deletions(-) diff --git a/app/definitions/IAttachment.ts b/app/definitions/IAttachment.ts index dc0e6f9ee74..3d759343556 100644 --- a/app/definitions/IAttachment.ts +++ b/app/definitions/IAttachment.ts @@ -1,5 +1,5 @@ export interface IAttachment { - title?: string; + title: string; title_link?: string; image_url?: string; image_type?: string; diff --git a/app/definitions/IRoom.ts b/app/definitions/IRoom.ts index f36dc05eaec..786c1d7c85b 100644 --- a/app/definitions/IRoom.ts +++ b/app/definitions/IRoom.ts @@ -4,7 +4,8 @@ export enum RoomType { GROUP = 'p', DIRECT = 'd', CHANNEL = 'c', - OMNICHANNEL = 'l' + OMNICHANNEL = 'l', + THREAD = 'thread' } export interface IRoom extends IRocketChatRecord { diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index 4c08f822c08..96dc03e9a32 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -11,13 +11,13 @@ export type MasterDetailChatsStackParamList = { t: RoomType; tmid?: string; message?: string; - name: string; - fname: string; + name?: string; + fname?: string; prid?: string; room: IRoom; jumpToMessageId?: string; jumpToThreadId?: string; - roomUserId: string; + roomUserId?: string; }; }; @@ -179,7 +179,7 @@ export type ModalStackParamList = { }; export type MasterDetailInsideStackParamList = { - DrawerNavigator: NavigatorScreenParams; + DrawerNavigator: NavigatorScreenParams>; // TODO: Changex ModalStackNavigator: NavigatorScreenParams; AttachmentView: { attachment: IAttachment; diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 0ae6de80825..e9ee5cbe407 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -1,6 +1,8 @@ import { NavigatorScreenParams } from '@react-navigation/core'; import { TextInputProps } from 'react-native'; +import Model from '@nozbe/watermelondb/Model'; +import { IOptionsField } from '../views/NotificationPreferencesView/options'; import { IServer } from '../definitions/IServer'; import { IAttachment } from '../definitions/IAttachment'; import { IMessage } from '../definitions/IMessage'; @@ -14,12 +16,12 @@ export type ChatsStackParamList = { tmid?: string; message?: string; name?: string; - fname: string; + fname?: string; prid?: string; room: IRoom; jumpToMessageId?: string; jumpToThreadId?: string; - roomUserId: string; + roomUserId?: string; }; RoomActionsView: { room: IRoom; @@ -58,11 +60,11 @@ export type ChatsStackParamList = { showCloseModal?: boolean; }; SelectedUsersView: { - maxUsers: number; - showButton: boolean; - title: string; - buttonText: string; - nextAction: Function; + maxUsers?: number; + showButton?: boolean; + title?: string; + buttonText?: string; + nextAction?: Function; }; InviteUsersView: { rid: string; @@ -82,7 +84,7 @@ export type ChatsStackParamList = { DirectoryView: undefined; NotificationPrefView: { rid: string; - room: IRoom; + room: Model; }; VisitorNavigationView: { rid: string; @@ -92,14 +94,14 @@ export type ChatsStackParamList = { }; LivechatEditView: { room: IRoom; - roomUser: any; // change + roomUser: any; // TODO: Change }; PickerView: { title: string; - data: []; // change - value: any; // change - onChangeText: TextInputProps['onChangeText']; - goBack: Function; + data: IOptionsField[]; + value?: any; // change + onChangeText?: (text: string) => IOptionsField[]; + goBack?: Function; onChangeValue: Function; }; ThreadMessagesView: { @@ -110,18 +112,19 @@ export type ChatsStackParamList = { teamId: string; }; CreateChannelView: { - isTeam?: boolean; // to check + isTeam?: boolean; // TODO: To check teamId?: string; }; AddChannelTeamView: { teamId?: string; - teamChannels: []; // change + teamChannels: []; // TODO: Change }; AddExistingChannelView: { - teamId?: boolean; + teamId?: string; + teamChannels: []; // TODO: Change }; MarkdownTableView: { - renderRows: Function; + renderRows: (drawExtraBorders?: boolean) => JSX.Element; tableWidth: number; }; ReadReceiptsView: { @@ -148,10 +151,10 @@ export type ProfileStackParamList = { UserNotificationPrefView: undefined; PickerView: { title: string; - data: []; // change - value: any; // change - onChangeText: TextInputProps['onChangeText']; - goBack: Function; + data: IOptionsField[]; + value: any; // TODO: Change + onChangeText?: TextInputProps['onChangeText']; + goBack?: Function; onChangeValue: Function; }; }; @@ -185,14 +188,14 @@ export type DrawerParamList = { export type NewMessageStackParamList = { NewMessageView: undefined; SelectedUsersViewCreateChannel: { - maxUsers: number; - showButton: boolean; - title: string; - buttonText: string; - nextAction: Function; - }; // to change + maxUsers?: number; + showButton?: boolean; + title?: string; + buttonText?: string; + nextAction?: Function; + }; // TODO: Change CreateChannelView: { - isTeam?: boolean; // to check + isTeam?: boolean; // TODO: To check teamId?: string; }; CreateDiscussionView: { @@ -204,8 +207,8 @@ export type NewMessageStackParamList = { export type E2ESaveYourPasswordStackParamList = { E2ESaveYourPasswordView: undefined; - E2EHowItWorksView: { - showCloseModal: boolean; + E2EHowItWorksView?: { + showCloseModal?: boolean; }; }; diff --git a/app/views/AddChannelTeamView.tsx b/app/views/AddChannelTeamView.tsx index d477f9badd8..8a72d3c967b 100644 --- a/app/views/AddChannelTeamView.tsx +++ b/app/views/AddChannelTeamView.tsx @@ -2,6 +2,7 @@ import React, { useEffect } from 'react'; import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; import { RouteProp } from '@react-navigation/native'; import { connect } from 'react-redux'; +import { CompositeNavigationProp } from '@react-navigation/core'; import * as List from '../containers/List'; import StatusBar from '../containers/StatusBar'; @@ -9,16 +10,24 @@ import { useTheme } from '../theme'; import * as HeaderButton from '../containers/HeaderButton'; import SafeAreaView from '../containers/SafeAreaView'; import I18n from '../i18n'; - -type TNavigation = StackNavigationProp; +import { ChatsStackParamList, DrawerParamList, NewMessageStackParamList } from '../stacks/types'; interface IAddChannelTeamView { - route: RouteProp<{ AddChannelTeamView: { teamId: string; teamChannels: object[] } }, 'AddChannelTeamView'>; - navigation: TNavigation; + navigation: CompositeNavigationProp< + StackNavigationProp, + CompositeNavigationProp, StackNavigationProp> + >; + route: RouteProp; isMasterDetail: boolean; } -const setHeader = (navigation: TNavigation, isMasterDetail: boolean) => { +const setHeader = ({ + navigation, + isMasterDetail +}: { + navigation: StackNavigationProp; + isMasterDetail: boolean; +}) => { const options: StackNavigationOptions = { headerTitle: I18n.t('Add_Channel_to_Team') }; @@ -35,7 +44,7 @@ const AddChannelTeamView = ({ navigation, route, isMasterDetail }: IAddChannelTe const { theme } = useTheme(); useEffect(() => { - setHeader(navigation, isMasterDetail); + setHeader({ navigation, isMasterDetail }); }, []); return ( diff --git a/app/views/AddExistingChannelView.tsx b/app/views/AddExistingChannelView.tsx index 5efdbf34d16..86ab9b9cf4e 100644 --- a/app/views/AddExistingChannelView.tsx +++ b/app/views/AddExistingChannelView.tsx @@ -21,6 +21,7 @@ import { animateNextTransition } from '../utils/layoutAnimation'; import { goRoom } from '../utils/goRoom'; import { showErrorAlert } from '../utils/info'; import debounce from '../utils/debounce'; +import { ChatsStackParamList } from '../stacks/types'; interface IAddExistingChannelViewState { // TODO: refactor with Room Model @@ -31,8 +32,8 @@ interface IAddExistingChannelViewState { } interface IAddExistingChannelViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ AddExistingChannelView: { teamId: string } }, 'AddExistingChannelView'>; + navigation: StackNavigationProp; + route: RouteProp; theme: string; isMasterDetail: boolean; addTeamChannelPermission: string[]; @@ -41,7 +42,7 @@ interface IAddExistingChannelViewProps { const QUERY_SIZE = 50; class AddExistingChannelView extends React.Component { - private teamId: string; + private teamId?: string; constructor(props: IAddExistingChannelViewProps) { super(props); this.query(); diff --git a/app/views/AttachmentView.tsx b/app/views/AttachmentView.tsx index 90adf8b42e8..09e2d5d6184 100644 --- a/app/views/AttachmentView.tsx +++ b/app/views/AttachmentView.tsx @@ -24,6 +24,8 @@ import { getUserSelector } from '../selectors/login'; import { withDimensions } from '../dimensions'; import { getHeaderHeight } from '../containers/Header'; import StatusBar from '../containers/StatusBar'; +import { InsideStackParamList } from '../stacks/types'; +import { IAttachment } from '../definitions/IAttachment'; const styles = StyleSheet.create({ container: { @@ -31,24 +33,14 @@ const styles = StyleSheet.create({ } }); -// TODO: refactor when react-navigation is done -export interface IAttachment { - title: string; - title_link?: string; - image_url?: string; - image_type?: string; - video_url?: string; - video_type?: string; -} - interface IAttachmentViewState { attachment: IAttachment; loading: boolean; } interface IAttachmentViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ AttachmentView: { attachment: IAttachment } }, 'AttachmentView'>; + navigation: StackNavigationProp; + route: RouteProp; theme: string; baseUrl: string; width: number; diff --git a/app/views/CreateChannelView.tsx b/app/views/CreateChannelView.tsx index 45b2cc2f27b..e8d719ab408 100644 --- a/app/views/CreateChannelView.tsx +++ b/app/views/CreateChannelView.tsx @@ -25,6 +25,7 @@ import { events, logEvent } from '../utils/log'; import SafeAreaView from '../containers/SafeAreaView'; import RocketChat from '../lib/rocketchat'; import sharedStyles from './Styles'; +import { ChatsStackParamList } from '../stacks/types'; const styles = StyleSheet.create({ container: { @@ -91,8 +92,8 @@ interface ICreateChannelViewState { } interface ICreateChannelViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ CreateChannelView: { isTeam: boolean; teamId: string } }, 'CreateChannelView'>; + navigation: StackNavigationProp; + route: RouteProp; baseUrl: string; create: (data: ICreateFunction) => void; removeUser: (user: IOtherUser) => void; @@ -118,7 +119,7 @@ interface ISwitch extends SwitchProps { } class CreateChannelView extends React.Component { - private teamId: string; + private teamId?: string; constructor(props: ICreateChannelViewProps) { super(props); @@ -240,7 +241,7 @@ class CreateChannelView extends React.Component void; theme: string; - navigation: StackNavigationProp; + navigation: StackNavigationProp; } class E2EEnterYourPasswordView extends React.Component { diff --git a/app/views/E2EHowItWorksView.tsx b/app/views/E2EHowItWorksView.tsx index 0fbdf77a180..fce1a2d0c61 100644 --- a/app/views/E2EHowItWorksView.tsx +++ b/app/views/E2EHowItWorksView.tsx @@ -9,6 +9,7 @@ import * as HeaderButton from '../containers/HeaderButton'; import Markdown from '../containers/markdown'; import { withTheme } from '../theme'; import I18n from '../i18n'; +import { E2ESaveYourPasswordStackParamList } from '../stacks/types'; const styles = StyleSheet.create({ container: { @@ -23,8 +24,8 @@ const styles = StyleSheet.create({ }); interface INavigation { - navigation: StackNavigationProp; - route: RouteProp<{ E2EHowItWorksView: { showCloseModal: boolean } }, 'E2EHowItWorksView'>; + navigation: StackNavigationProp; + route: RouteProp; } interface IE2EHowItWorksViewProps extends INavigation { diff --git a/app/views/E2ESaveYourPasswordView.tsx b/app/views/E2ESaveYourPasswordView.tsx index 1c4e13a5a95..3d9a32ee12c 100644 --- a/app/views/E2ESaveYourPasswordView.tsx +++ b/app/views/E2ESaveYourPasswordView.tsx @@ -19,6 +19,7 @@ import Button from '../containers/Button'; import { withTheme } from '../theme'; import I18n from '../i18n'; import sharedStyles from './Styles'; +import { E2ESaveYourPasswordStackParamList } from '../stacks/types'; const styles = StyleSheet.create({ container: { @@ -60,7 +61,7 @@ interface IE2ESaveYourPasswordViewState { interface IE2ESaveYourPasswordViewProps { server: string; - navigation: StackNavigationProp; + navigation: StackNavigationProp; encryptionSetBanner(): void; theme: string; } diff --git a/app/views/ForgotPasswordView.tsx b/app/views/ForgotPasswordView.tsx index c08a1acdd67..375d089d420 100644 --- a/app/views/ForgotPasswordView.tsx +++ b/app/views/ForgotPasswordView.tsx @@ -14,6 +14,7 @@ import { themes } from '../constants/colors'; import FormContainer, { FormContainerInner } from '../containers/FormContainer'; import { events, logEvent } from '../utils/log'; import sharedStyles from './Styles'; +import { OutsideParamList } from '../stacks/types'; interface IForgotPasswordViewState { email: string; @@ -22,8 +23,8 @@ interface IForgotPasswordViewState { } interface IForgotPasswordViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ ForgotPasswordView: { title: string } }, 'ForgotPasswordView'>; + navigation: StackNavigationProp; + route: RouteProp; theme: string; } diff --git a/app/views/ForwardLivechatView.tsx b/app/views/ForwardLivechatView.tsx index 42a29782d9d..b0759b20ed1 100644 --- a/app/views/ForwardLivechatView.tsx +++ b/app/views/ForwardLivechatView.tsx @@ -14,6 +14,7 @@ import OrSeparator from '../containers/OrSeparator'; import Input from '../containers/UIKit/MultiSelect/Input'; import { forwardRoom as forwardRoomAction } from '../actions/room'; import { ILivechatDepartment } from './definition/ILivechatDepartment'; +import { ChatsStackParamList } from '../stacks/types'; const styles = StyleSheet.create({ container: { @@ -47,8 +48,8 @@ interface IParsedData { } interface IForwardLivechatViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ ForwardLivechatView: { rid: string } }, 'ForwardLivechatView'>; + navigation: StackNavigationProp; + route: RouteProp; theme: string; forwardRoom: (rid: string, transferData: ITransferData) => void; } @@ -146,8 +147,7 @@ const ForwardLivechatView = ({ forwardRoom, navigation, route, theme }: IForward title: I18n.t('Forward_to_department'), value: room?.departmentId, data: departments, - onChangeValue: setDepartment, - goBack: false + onChangeValue: setDepartment }); }; @@ -156,8 +156,7 @@ const ForwardLivechatView = ({ forwardRoom, navigation, route, theme }: IForward title: I18n.t('Forward_to_user'), data: users, onChangeValue: setUser, - onChangeText: getUsers, - goBack: false + onChangeText: getUsers }); }; diff --git a/app/views/InviteUsersEditView/index.tsx b/app/views/InviteUsersEditView/index.tsx index f7c94e147af..4ae1a67dfd3 100644 --- a/app/views/InviteUsersEditView/index.tsx +++ b/app/views/InviteUsersEditView/index.tsx @@ -19,6 +19,7 @@ import { withTheme } from '../../theme'; import SafeAreaView from '../../containers/SafeAreaView'; import { events, logEvent } from '../../utils/log'; import styles from './styles'; +import { ChatsStackParamList } from '../../stacks/types'; const OPTIONS = { days: [ @@ -68,8 +69,8 @@ const OPTIONS = { }; interface IInviteUsersEditViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ InviteUsersEditView: { rid: string } }, 'InviteUsersEditView'>; + navigation: StackNavigationProp; + route: RouteProp; theme: string; createInviteLink(rid: string): void; inviteLinksSetParams(params: { [key: string]: number }): void; diff --git a/app/views/JitsiMeetView.tsx b/app/views/JitsiMeetView.tsx index 44034cda215..aa6658d200c 100644 --- a/app/views/JitsiMeetView.tsx +++ b/app/views/JitsiMeetView.tsx @@ -12,6 +12,7 @@ import ActivityIndicator from '../containers/ActivityIndicator'; import { events, logEvent } from '../utils/log'; import { isAndroid, isIOS } from '../utils/deviceInfo'; import { withTheme } from '../theme'; +import { InsideStackParamList } from '../stacks/types'; const formatUrl = (url: string, baseUrl: string, uriSize: number, avatarAuthURLFragment: string) => `${baseUrl}/avatar/${url}?format=png&width=${uriSize}&height=${uriSize}${avatarAuthURLFragment}`; @@ -25,8 +26,8 @@ interface IJitsiMeetViewState { } interface IJitsiMeetViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ JitsiMeetView: { rid: string; url: string; onlyAudio?: boolean } }, 'JitsiMeetView'>; + navigation: StackNavigationProp; + route: RouteProp; baseUrl: string; theme: string; user: { diff --git a/app/views/MarkdownTableView.tsx b/app/views/MarkdownTableView.tsx index a65994eefa4..e260199e0e6 100644 --- a/app/views/MarkdownTableView.tsx +++ b/app/views/MarkdownTableView.tsx @@ -7,12 +7,10 @@ import I18n from '../i18n'; import { isIOS } from '../utils/deviceInfo'; import { themes } from '../constants/colors'; import { withTheme } from '../theme'; +import { ChatsStackParamList } from '../stacks/types'; interface IMarkdownTableViewProps { - route: RouteProp< - { MarkdownTableView: { renderRows: (drawExtraBorders?: boolean) => JSX.Element; tableWidth: number } }, - 'MarkdownTableView' - >; + route: RouteProp; theme: string; } diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index 5f0fa136c06..14532051b35 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -5,7 +5,7 @@ import { dequal } from 'dequal'; import { StackNavigationProp } from '@react-navigation/stack'; import { CompositeNavigationProp, RouteProp } from '@react-navigation/core'; -import { MasterDetailInsideStackParamList, ModalStackParamList } from '../../stacks/MasterDetailStack/types'; +import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types'; import Message from '../../containers/message'; import ActivityIndicator from '../../containers/ActivityIndicator'; import I18n from '../../i18n'; @@ -29,7 +29,7 @@ interface IMessagesViewProps { baseUrl: string; navigation: CompositeNavigationProp< StackNavigationProp, - CompositeNavigationProp, StackNavigationProp> + StackNavigationProp >; route: RouteProp; customEmojis: { [key: string]: string }; @@ -71,17 +71,22 @@ interface IMessageItem { } interface IParams { - rid?: string; - jumpToMessageId: string; - t?: string; - room: any; + rid: string; + t: RoomType; tmid?: string; + message?: string; name?: string; + fname?: string; + prid?: string; + room: IRoom; + jumpToMessageId?: string; + jumpToThreadId?: string; + roomUserId?: string; } class MessagesView extends React.Component { - private rid?: string; - private t?: string; + private rid: string; + private t: RoomType; private content: any; private room: any; @@ -153,7 +158,7 @@ class MessagesView extends React.Component { ...params, tmid: item.tmid, name: await getThreadName(this.rid, item.tmid, item._id), - t: 'thread' + t: RoomType.THREAD }; navigation.push('RoomView', params); } else { diff --git a/app/views/NewServerView/index.tsx b/app/views/NewServerView/index.tsx index f1458c93ad1..aaacdf90f01 100644 --- a/app/views/NewServerView/index.tsx +++ b/app/views/NewServerView/index.tsx @@ -33,6 +33,7 @@ import { isTablet } from '../../utils/deviceInfo'; import { verticalScale, moderateScale } from '../../utils/scaling'; import { withDimensions } from '../../dimensions'; import ServerInput from './ServerInput'; +import { OutsideParamList } from '../../stacks/types'; const styles = StyleSheet.create({ onboardingImage: { @@ -73,7 +74,7 @@ export interface IServer extends Model { } interface INewServerView { - navigation: StackNavigationProp; + navigation: StackNavigationProp; theme: string; connecting: boolean; connectServer(server: string, username?: string, fromServerHistory?: boolean): void; diff --git a/app/views/NotificationPreferencesView/index.tsx b/app/views/NotificationPreferencesView/index.tsx index a020c1631ab..5e33cec491d 100644 --- a/app/views/NotificationPreferencesView/index.tsx +++ b/app/views/NotificationPreferencesView/index.tsx @@ -17,6 +17,7 @@ import SafeAreaView from '../../containers/SafeAreaView'; import log, { events, logEvent } from '../../utils/log'; import sharedStyles from '../Styles'; import { OPTIONS } from './options'; +import { ChatsStackParamList } from '../../stacks/types'; const styles = StyleSheet.create({ pickerText: { @@ -26,16 +27,8 @@ const styles = StyleSheet.create({ }); interface INotificationPreferencesView { - navigation: StackNavigationProp; - route: RouteProp< - { - NotificationPreferencesView: { - rid: string; - room: Model; - }; - }, - 'NotificationPreferencesView' - >; + navigation: StackNavigationProp; + route: RouteProp; theme: string; } diff --git a/app/views/NotificationPreferencesView/options.ts b/app/views/NotificationPreferencesView/options.ts index 4035c038019..a2b3251c6a2 100644 --- a/app/views/NotificationPreferencesView/options.ts +++ b/app/views/NotificationPreferencesView/options.ts @@ -1,4 +1,4 @@ -interface IOptionsField { +export interface IOptionsField { label: string; value: string | number; second?: number; diff --git a/app/views/PickerView.tsx b/app/views/PickerView.tsx index 002979b20aa..570d8e4bda4 100644 --- a/app/views/PickerView.tsx +++ b/app/views/PickerView.tsx @@ -11,6 +11,8 @@ import * as List from '../containers/List'; import SearchBox from '../containers/SearchBox'; import SafeAreaView from '../containers/SafeAreaView'; import sharedStyles from './Styles'; +import { ChatsStackParamList } from '../stacks/types'; +import { IOptionsField } from './NotificationPreferencesView/options'; const styles = StyleSheet.create({ search: { @@ -25,37 +27,21 @@ const styles = StyleSheet.create({ } }); -interface IData { - label: string; - value: string; - second?: string; -} - interface IItem { - item: IData; + item: IOptionsField; selected: boolean; onItemPress: () => void; theme: string; } interface IPickerViewState { - data: IData[]; - value: string; -} - -interface IParams { - title: string; + data: IOptionsField[]; value: string; - data: IData[]; - onChangeText: (value: string) => IData[]; - goBack: boolean; - onChange: Function; - onChangeValue: (value: string) => void; } interface IPickerViewProps { - navigation: StackNavigationProp; - route: RouteProp<{ PickerView: IParams }, 'PickerView'>; + navigation: StackNavigationProp; + route: RouteProp; theme: string; } @@ -69,7 +55,7 @@ const Item = React.memo(({ item, selected, onItemPress, theme }: IItem) => ( )); class PickerView extends React.PureComponent { - private onSearch: (text: string) => IData[]; + private onSearch?: (text: string) => IOptionsField[]; static navigationOptions = ({ route }: IPickerViewProps) => ({ title: route.params?.title ?? I18n.t('Select_an_option') @@ -126,13 +112,13 @@ class PickerView extends React.PureComponent {this.renderSearch()} item.value} + keyExtractor={item => item.value as string} renderItem={({ item }) => ( this.onChangeValue(item.value)} + onItemPress={() => this.onChangeValue(item.value as string)} /> )} ItemSeparatorComponent={List.Separator} diff --git a/app/views/ReadReceiptView/index.tsx b/app/views/ReadReceiptView/index.tsx index 9f1a00675fa..a40327b21ad 100644 --- a/app/views/ReadReceiptView/index.tsx +++ b/app/views/ReadReceiptView/index.tsx @@ -16,6 +16,7 @@ import { withTheme } from '../../theme'; import { themes } from '../../constants/colors'; import SafeAreaView from '../../containers/SafeAreaView'; import styles from './styles'; +import { ChatsStackParamList } from '../../stacks/types'; interface IReceipts { _id: string; @@ -36,8 +37,8 @@ interface IReadReceiptViewState { } interface INavigationOption { - navigation: StackNavigationProp; - route: RouteProp<{ ReadReceiptView: { messageId: string } }, 'ReadReceiptView'>; + navigation: StackNavigationProp; + route: RouteProp; isMasterDetail: boolean; } diff --git a/app/views/RegisterView.tsx b/app/views/RegisterView.tsx index 17b7cf63697..ae5f46bd9e5 100644 --- a/app/views/RegisterView.tsx +++ b/app/views/RegisterView.tsx @@ -52,7 +52,7 @@ const styles = StyleSheet.create({ }); interface IProps { - navigation: StackNavigationProp; + navigation: StackNavigationProp; route: RouteProp; server: string; Site_Name: string; diff --git a/app/views/SidebarView/index.tsx b/app/views/SidebarView/index.tsx index f97e3ea992d..d8cfa38cad1 100644 --- a/app/views/SidebarView/index.tsx +++ b/app/views/SidebarView/index.tsx @@ -18,6 +18,7 @@ import SafeAreaView from '../../containers/SafeAreaView'; import Navigation from '../../lib/Navigation'; import SidebarItem from './SidebarItem'; import styles from './styles'; +import { DrawerParamList } from '../../stacks/types'; interface ISeparatorProps { theme: string; @@ -34,8 +35,8 @@ interface ISidebarState { interface ISidebarProps { baseUrl: string; - navigation: DrawerNavigationProp; - state: DrawerNavigationState; + navigation: DrawerNavigationProp; + state: DrawerNavigationState; Site_Name: string; user: { statusText: string; diff --git a/app/views/UserNotificationPreferencesView/index.tsx b/app/views/UserNotificationPreferencesView/index.tsx index 541d5da81a5..8961cb38f79 100644 --- a/app/views/UserNotificationPreferencesView/index.tsx +++ b/app/views/UserNotificationPreferencesView/index.tsx @@ -14,6 +14,7 @@ import ActivityIndicator from '../../containers/ActivityIndicator'; import { getUserSelector } from '../../selectors/login'; import sharedStyles from '../Styles'; import { OPTIONS } from './options'; +import { ProfileStackParamList } from '../../stacks/types'; const styles = StyleSheet.create({ pickerText: { @@ -34,7 +35,7 @@ interface IUserNotificationPreferencesViewState { } interface IUserNotificationPreferencesViewProps { - navigation: StackNavigationProp; + navigation: StackNavigationProp; theme: string; user: { id: string; diff --git a/app/views/WithoutServersView.tsx b/app/views/WithoutServersView.tsx index b7771983937..43ceacc2d63 100644 --- a/app/views/WithoutServersView.tsx +++ b/app/views/WithoutServersView.tsx @@ -26,7 +26,11 @@ const styles = StyleSheet.create({ } }); -class WithoutServerView extends React.Component { +interface IWithoutServerViewProps { + theme: string; +} + +class WithoutServerView extends React.Component { static navigationOptions = () => ({ title: 'Rocket.Chat', headerLeft: () => From 88a91f5b360a113633cd08569cb603dad4f16529 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Mon, 22 Nov 2021 18:38:07 -0400 Subject: [PATCH 09/23] navigationTypes for AppContainer --- app/AppContainer.tsx | 5 +++-- app/navigationTypes.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 app/navigationTypes.ts diff --git a/app/AppContainer.tsx b/app/AppContainer.tsx index f7f08bb27db..b73aaf8e3f8 100644 --- a/app/AppContainer.tsx +++ b/app/AppContainer.tsx @@ -3,6 +3,7 @@ import { NavigationContainer } from '@react-navigation/native'; import { createStackNavigator } from '@react-navigation/stack'; import { connect } from 'react-redux'; +import { SetUsernameStackParamList, StackParamList } from './navigationTypes'; import Navigation from './lib/Navigation'; import { defaultHeader, getActiveRouteName, navigationTheme } from './utils/navigation'; import { ROOT_INSIDE, ROOT_LOADING, ROOT_OUTSIDE, ROOT_SET_USERNAME } from './actions/app'; @@ -17,7 +18,7 @@ import { ThemeContext } from './theme'; import { setCurrentScreen } from './utils/log'; // SetUsernameStack -const SetUsername = createStackNavigator(); +const SetUsername = createStackNavigator(); const SetUsernameStack = () => ( @@ -25,7 +26,7 @@ const SetUsernameStack = () => ( ); // App -const Stack = createStackNavigator(); +const Stack = createStackNavigator(); const App = React.memo(({ root, isMasterDetail }: { root: string; isMasterDetail: boolean }) => { if (!root) { return null; diff --git a/app/navigationTypes.ts b/app/navigationTypes.ts new file mode 100644 index 00000000000..10baf7542e0 --- /dev/null +++ b/app/navigationTypes.ts @@ -0,0 +1,18 @@ +import { NavigatorScreenParams } from '@react-navigation/core'; + +import { MasterDetailInsideStackParamList } from './stacks/MasterDetailStack/types'; +import { OutsideParamList, InsideStackParamList } from './stacks/types'; + +export type SetUsernameStackParamList = { + SetUsernameView: { + title: string; + }; +}; + +export type StackParamList = { + AuthLoading: undefined; + OutsideStack: NavigatorScreenParams; + InsideStack: NavigatorScreenParams; + MasterDetailStack: NavigatorScreenParams; + SetUsernameStack: NavigatorScreenParams; +}; From f8f0ecac31119a1509f81d9dd660596e70df9e96 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Tue, 23 Nov 2021 11:04:29 -0400 Subject: [PATCH 10/23] added share navigationTypes, updated stack types and masterdetail types --- app/navigationTypes.ts | 27 +++++++++++++++++++++++++++ app/share.tsx | 16 ++++++---------- app/stacks/MasterDetailStack/types.ts | 18 +++++++++--------- app/stacks/types.ts | 6 +++--- 4 files changed, 45 insertions(+), 22 deletions(-) diff --git a/app/navigationTypes.ts b/app/navigationTypes.ts index 10baf7542e0..568b75d0fa5 100644 --- a/app/navigationTypes.ts +++ b/app/navigationTypes.ts @@ -1,5 +1,8 @@ import { NavigatorScreenParams } from '@react-navigation/core'; +import { IRoom } from './definitions/IRoom'; +import { IServer } from './definitions/IServer'; +import { IAttachment } from './definitions/IAttachment'; import { MasterDetailInsideStackParamList } from './stacks/MasterDetailStack/types'; import { OutsideParamList, InsideStackParamList } from './stacks/types'; @@ -16,3 +19,27 @@ export type StackParamList = { MasterDetailStack: NavigatorScreenParams; SetUsernameStack: NavigatorScreenParams; }; + +export type ShareInsideStackParamList = { + ShareListView: undefined; + ShareView: { + attachments: IAttachment[]; + isShareView?: boolean; + isShareExtension: boolean; + serverInfo: IServer; + text: string; + room: IRoom; + thread: any; // TODO: Change + }; + SelectServerView: undefined; +}; + +export type ShareOutsideStackParamList = { + WithoutServersView: undefined; +}; + +export type ShareAppStackParamList = { + AuthLoading?: undefined; + OutsideStack?: NavigatorScreenParams; + InsideStack?: NavigatorScreenParams; +}; diff --git a/app/share.tsx b/app/share.tsx index ceb85477dcc..daee2fba0bf 100644 --- a/app/share.tsx +++ b/app/share.tsx @@ -25,6 +25,7 @@ import { setCurrentScreen } from './utils/log'; import AuthLoadingView from './views/AuthLoadingView'; import { DimensionsContext } from './dimensions'; import debounce from './utils/debounce'; +import { ShareInsideStackParamList, ShareOutsideStackParamList, ShareAppStackParamList } from './navigationTypes'; interface IDimensions { width: number; @@ -46,7 +47,7 @@ interface IState { fontScale: number; } -const Inside = createStackNavigator(); +const Inside = createStackNavigator(); const InsideStack = () => { const { theme } = useContext(ThemeContext); @@ -65,24 +66,19 @@ const InsideStack = () => { ); }; -const Outside = createStackNavigator(); +const Outside = createStackNavigator(); const OutsideStack = () => { const { theme } = useContext(ThemeContext); return ( - + ); }; // App -const Stack = createStackNavigator(); +const Stack = createStackNavigator(); export const App = ({ root }: any) => ( <> @@ -112,7 +108,7 @@ class Root extends React.Component<{}, IState> { this.init(); } - componentWillUnmount() { + componentWillUnmount(): void { RocketChat.closeShareExtension(); unsubscribeTheme(); } diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index 96dc03e9a32..2e5246c25f9 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -74,7 +74,7 @@ export type ModalStackParamList = { }; AddChannelTeamView: { teamId?: string; - teamChannels: []; // change + teamChannels: []; // TODO: Change }; AddExistingChannelView: { teamId?: boolean; @@ -117,12 +117,12 @@ export type ModalStackParamList = { }; LivechatEditView: { room: IRoom; - roomUser: any; // change + roomUser: any; // TODO: Change }; PickerView: { title: string; - data: []; // change - value: any; // change + data: []; // TODO: Change + value: any; // TODO: Change onChangeText: TextInputProps['onChangeText']; goBack: Function; onChangeValue: Function; @@ -157,9 +157,9 @@ export type ModalStackParamList = { title: string; buttonText: string; nextAction: Function; - }; // to change + }; // TODO: Change CreateChannelView: { - isTeam?: boolean; // to check + isTeam?: boolean; // TODO: To check teamId?: string; }; CreateDiscussionView: { @@ -179,13 +179,13 @@ export type ModalStackParamList = { }; export type MasterDetailInsideStackParamList = { - DrawerNavigator: NavigatorScreenParams>; // TODO: Changex + DrawerNavigator: NavigatorScreenParams>; // TODO: Change ModalStackNavigator: NavigatorScreenParams; AttachmentView: { attachment: IAttachment; }; ModalBlockView: { - data: any; // change; + data: any; // TODO: Change }; JitsiMeetView: { rid: string; @@ -198,6 +198,6 @@ export type MasterDetailInsideStackParamList = { serverInfo: {}; text: string; room: IRoom; - thread: any; // change + thread: any; // TODO: Change }; }; diff --git a/app/stacks/types.ts b/app/stacks/types.ts index e9ee5cbe407..396b4c9d2ff 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -99,7 +99,7 @@ export type ChatsStackParamList = { PickerView: { title: string; data: IOptionsField[]; - value?: any; // change + value?: any; // TODO: Change onChangeText?: (text: string) => IOptionsField[]; goBack?: Function; onChangeValue: Function; @@ -232,10 +232,10 @@ export type InsideStackParamList = { serverInfo: IServer; text: string; room: IRoom; - thread: any; // change + thread: any; // TODO: Change }; ModalBlockView: { - data: any; // change; + data: any; // TODO: Change; }; JitsiMeetView: { rid: string; From e917585006a86a515b2972f35f747f957e393312 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 12:09:06 -0300 Subject: [PATCH 11/23] refactor: minor tweak --- app/views/CreateDiscussionView/index.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/CreateDiscussionView/index.tsx b/app/views/CreateDiscussionView/index.tsx index 18319529f2a..53d741d2d21 100644 --- a/app/views/CreateDiscussionView/index.tsx +++ b/app/views/CreateDiscussionView/index.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { connect } from 'react-redux'; import { ScrollView, Switch, Text } from 'react-native'; +import { StackNavigationOptions } from '@react-navigation/stack'; import Loading from '../../containers/Loading'; import KeyboardView from '../../presentation/KeyboardView'; @@ -82,15 +83,14 @@ class CreateChannelView extends React.Component { navigation.setOptions({ title: I18n.t('Create_Discussion'), headerRight: this.valid() - ? () => - ( - - - - ) as React.ReactNode + ? () => ( + + + + ) : null, headerLeft: showCloseModal ? () => : undefined - }); + } as StackNavigationOptions); }; submit = () => { From f336c0d9e3591856764520788820657e9b7f4fc5 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 13:32:51 -0300 Subject: [PATCH 12/23] refactor: minor tweak --- app/views/LoginView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/LoginView.tsx b/app/views/LoginView.tsx index ef965a78dc0..e43505f3f1e 100644 --- a/app/views/LoginView.tsx +++ b/app/views/LoginView.tsx @@ -71,7 +71,7 @@ interface ILoginViewProps { class LoginView extends React.Component { private passwordInput: any; - static navigationOptions = ({ route, navigation }: Partial) => ({ + static navigationOptions = ({ route, navigation }: ILoginViewProps) => ({ title: route?.params?.title ?? 'Rocket.Chat', headerRight: () => }); From d05a603d11bcc4bf7e4e1ce7e9f940ddf87135cc Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 14:39:19 -0300 Subject: [PATCH 13/23] refactor: minor tweak --- app/stacks/types.ts | 2 ++ app/views/SettingsView/index.tsx | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 396b4c9d2ff..41dec845874 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -167,6 +167,8 @@ export type SettingsStackParamList = { ThemeView: undefined; DefaultBrowserView: undefined; ScreenLockConfigView: undefined; + ProfileView: undefined; + DisplayPrefsView: undefined; }; export type AdminPanelStackParamList = { diff --git a/app/views/SettingsView/index.tsx b/app/views/SettingsView/index.tsx index 4fbfc881c6e..edad2822e2e 100644 --- a/app/views/SettingsView/index.tsx +++ b/app/views/SettingsView/index.tsx @@ -48,7 +48,7 @@ interface ISettingsViewProps { } class SettingsView extends React.Component { - static navigationOptions = ({ navigation, isMasterDetail }: Partial) => ({ + static navigationOptions = ({ navigation, isMasterDetail }: ISettingsViewProps) => ({ headerLeft: () => isMasterDetail ? ( @@ -118,7 +118,7 @@ class SettingsView extends React.Component { }); }; - navigateToScreen = (screen: string) => { + navigateToScreen = (screen: keyof SettingsStackParamList) => { /* @ts-ignore */ logEvent(events[`SE_GO_${screen.replace('View', '').toUpperCase()}`]); const { navigation } = this.props; From 6b8c8869779df6035c8f024c1c76f31616d37070 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 14:55:22 -0300 Subject: [PATCH 14/23] refactor: completing the interface IAttachment --- app/definitions/IAttachment.ts | 2 ++ app/utils/fileDownload/index.ts | 8 +------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/app/definitions/IAttachment.ts b/app/definitions/IAttachment.ts index 3d759343556..168106177ff 100644 --- a/app/definitions/IAttachment.ts +++ b/app/definitions/IAttachment.ts @@ -1,5 +1,7 @@ export interface IAttachment { title: string; + type: string; + description: string; title_link?: string; image_url?: string; image_type?: string; diff --git a/app/utils/fileDownload/index.ts b/app/utils/fileDownload/index.ts index dda1a78ff54..279d3b3a564 100644 --- a/app/utils/fileDownload/index.ts +++ b/app/utils/fileDownload/index.ts @@ -5,13 +5,7 @@ import EventEmitter from '../events'; import { LISTENER } from '../../containers/Toast'; import I18n from '../../i18n'; import { DOCUMENTS_PATH, DOWNLOAD_PATH } from '../../constants/localPath'; - -interface IAttachment { - title: string; - title_link: string; - type: string; - description: string; -} +import { IAttachment } from '../../definitions/IAttachment'; export const getLocalFilePathFromFile = (localPath: string, attachment: IAttachment): string => `${localPath}${attachment.title}`; From 4659c63c9dfc050f2c6855952e30b4150ea87b71 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 15:13:55 -0300 Subject: [PATCH 15/23] refactor: minor tweak --- app/stacks/types.ts | 4 ++-- app/views/ForwardLivechatView.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 41dec845874..28d77592ab4 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -100,8 +100,8 @@ export type ChatsStackParamList = { title: string; data: IOptionsField[]; value?: any; // TODO: Change - onChangeText?: (text: string) => IOptionsField[]; - goBack?: Function; + onChangeText?: Function; + goBack?: boolean; onChangeValue: Function; }; ThreadMessagesView: { diff --git a/app/views/ForwardLivechatView.tsx b/app/views/ForwardLivechatView.tsx index b0759b20ed1..ea17466dd55 100644 --- a/app/views/ForwardLivechatView.tsx +++ b/app/views/ForwardLivechatView.tsx @@ -147,7 +147,8 @@ const ForwardLivechatView = ({ forwardRoom, navigation, route, theme }: IForward title: I18n.t('Forward_to_department'), value: room?.departmentId, data: departments, - onChangeValue: setDepartment + onChangeValue: setDepartment, + goBack: false }); }; @@ -156,7 +157,8 @@ const ForwardLivechatView = ({ forwardRoom, navigation, route, theme }: IForward title: I18n.t('Forward_to_user'), data: users, onChangeValue: setUser, - onChangeText: getUsers + onChangeText: getUsers, + goBack: false }); }; From 4287d9cdffca36280206d68e9717ea173d4bc8b9 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 15:26:22 -0300 Subject: [PATCH 16/23] refactor: minor tweak --- app/definitions/{ITeam.js => ITeam.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/definitions/{ITeam.js => ITeam.ts} (100%) diff --git a/app/definitions/ITeam.js b/app/definitions/ITeam.ts similarity index 100% rename from app/definitions/ITeam.js rename to app/definitions/ITeam.ts From d05a7b82acd4026fe8b5c5c2c3e95b0da9622a07 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 1 Dec 2021 17:03:15 -0400 Subject: [PATCH 17/23] update withTheme param type and remove unnecessary options --- app/dimensions.tsx | 2 +- app/ee/omnichannel/views/QueueListView.js | 1 + app/stacks/InsideStack.tsx | 34 +++++------------------ app/theme.tsx | 8 +++++- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/app/dimensions.tsx b/app/dimensions.tsx index dc164362a89..5b47eaf991c 100644 --- a/app/dimensions.tsx +++ b/app/dimensions.tsx @@ -22,7 +22,7 @@ export interface IDimensionsContextProps { export const DimensionsContext = React.createContext>(Dimensions.get('window')); -export function withDimensions(Component: any) { +export function withDimensions(Component: any): typeof Component { const DimensionsComponent = (props: any) => ( {contexts => } ); diff --git a/app/ee/omnichannel/views/QueueListView.js b/app/ee/omnichannel/views/QueueListView.js index defe9233ff6..5d537ceef72 100644 --- a/app/ee/omnichannel/views/QueueListView.js +++ b/app/ee/omnichannel/views/QueueListView.js @@ -161,4 +161,5 @@ const mapStateToProps = state => ({ showAvatar: state.sortPreferences.showAvatar, displayMode: state.sortPreferences.displayMode }); + export default connect(mapStateToProps)(withDimensions(withTheme(QueueListView))); diff --git a/app/stacks/InsideStack.tsx b/app/stacks/InsideStack.tsx index 66967f71ba1..97b3b25de00 100644 --- a/app/stacks/InsideStack.tsx +++ b/app/stacks/InsideStack.tsx @@ -93,7 +93,7 @@ const ChatsStackNavigator = () => { - + { component={ThreadMessagesView} options={ThreadMessagesView.navigationOptions} /> - + - + { - - + + ); }; @@ -168,11 +156,7 @@ const ProfileStackNavigator = () => { - + { - + void; } +type TOptions = { + navigationOptions?: StackNavigationOptions; +}; + export const ThemeContext = React.createContext({ theme: 'light' }); -export function withTheme(Component: any) { +export function withTheme(Component: React.ComponentType & TOptions): typeof Component { const ThemedComponent = (props: any) => ( {contexts => } ); + ThemedComponent.navigationOptions = Component.navigationOptions; hoistNonReactStatics(ThemedComponent, Component); return ThemedComponent; } From 0cf961fdbea20ce64501c44cca38edad850d281b Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 1 Dec 2021 17:21:17 -0400 Subject: [PATCH 18/23] Undo withTheme changes to open a new PR around it --- app/theme.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/theme.tsx b/app/theme.tsx index fdc2f7edb57..4accff2cd89 100644 --- a/app/theme.tsx +++ b/app/theme.tsx @@ -1,6 +1,5 @@ import React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; -import { StackNavigationOptions } from '@react-navigation/stack'; interface IThemeContextProps { theme: string; @@ -11,17 +10,12 @@ interface IThemeContextProps { setTheme?: (newTheme?: {}) => void; } -type TOptions = { - navigationOptions?: StackNavigationOptions; -}; - export const ThemeContext = React.createContext({ theme: 'light' }); -export function withTheme(Component: React.ComponentType & TOptions): typeof Component { +export function withTheme(Component: any) { const ThemedComponent = (props: any) => ( {contexts => } ); - ThemedComponent.navigationOptions = Component.navigationOptions; hoistNonReactStatics(ThemedComponent, Component); return ThemedComponent; } From 4edb5910d45a9d0b329bc8a0dc978c8896fd3d69 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 20:08:06 -0300 Subject: [PATCH 19/23] refactor: Undo withTheme changes to open a new PR around it --- app/theme.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/theme.tsx b/app/theme.tsx index 4accff2cd89..635ffda1cbb 100644 --- a/app/theme.tsx +++ b/app/theme.tsx @@ -12,7 +12,7 @@ interface IThemeContextProps { export const ThemeContext = React.createContext({ theme: 'light' }); -export function withTheme(Component: any) { +export function withTheme(Component: any): any { const ThemedComponent = (props: any) => ( {contexts => } ); From 81b2769eece4cc691157186ac2192b01c38098cb Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Wed, 1 Dec 2021 20:09:45 -0300 Subject: [PATCH 20/23] refactor: change the HOC to improvement on next PR --- app/containers/ActionSheet/Provider.tsx | 2 +- app/dimensions.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/containers/ActionSheet/Provider.tsx b/app/containers/ActionSheet/Provider.tsx index 0e58ae5723c..8e786b05f58 100644 --- a/app/containers/ActionSheet/Provider.tsx +++ b/app/containers/ActionSheet/Provider.tsx @@ -17,7 +17,7 @@ export const useActionSheet = () => useContext(context); const { Provider, Consumer } = context; -export const withActionSheet =

(Component: React.ComponentType

) => +export const withActionSheet = (Component: any): any => forwardRef((props: any, ref: ForwardedRef) => ( {(contexts: any) => } )); diff --git a/app/dimensions.tsx b/app/dimensions.tsx index 5b47eaf991c..67600968309 100644 --- a/app/dimensions.tsx +++ b/app/dimensions.tsx @@ -22,7 +22,7 @@ export interface IDimensionsContextProps { export const DimensionsContext = React.createContext>(Dimensions.get('window')); -export function withDimensions(Component: any): typeof Component { +export function withDimensions(Component: any): any { const DimensionsComponent = (props: any) => ( {contexts => } ); From adfa5d2ca444dbf6dd0911d8ceda662bf3e585da Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Thu, 2 Dec 2021 11:38:25 -0400 Subject: [PATCH 21/23] Fix interfaces and temp solution for screens --- app/containers/EmojiPicker/index.tsx | 6 ++-- app/containers/LoginServices.tsx | 2 +- app/containers/MessageBox/EmojiKeyboard.tsx | 2 +- app/containers/MessageBox/index.tsx | 2 +- app/stacks/MasterDetailStack/index.tsx | 31 ++++----------------- app/stacks/OutsideStack.tsx | 6 +--- app/stacks/types.ts | 2 +- app/views/PickerView.tsx | 2 +- app/views/SidebarView/index.tsx | 2 +- 9 files changed, 16 insertions(+), 39 deletions(-) diff --git a/app/containers/EmojiPicker/index.tsx b/app/containers/EmojiPicker/index.tsx index 64f5dbfe3a7..94d70e89da4 100644 --- a/app/containers/EmojiPicker/index.tsx +++ b/app/containers/EmojiPicker/index.tsx @@ -31,7 +31,7 @@ interface IEmojiPickerProps { customEmojis?: any; style: object; theme?: string; - onEmojiSelected?: Function; + onEmojiSelected?: (emoji: any) => void; tabEmojiStyle?: object; } @@ -97,7 +97,7 @@ class EmojiPicker extends Component { const content = emoji; this._addFrequentlyUsed({ content, isCustom: false }); const shortname = `:${emoji}:`; - onEmojiSelected!(shortnameToUnicode(shortname), shortname); + onEmojiSelected!(shortnameToUnicode(shortname)); } } catch (e) { log(e); @@ -201,4 +201,4 @@ const mapStateToProps = (state: any) => ({ customEmojis: state.customEmojis }); -export default connect(mapStateToProps)(withTheme(EmojiPicker)); +export default connect(mapStateToProps)(withTheme(EmojiPicker)) as any; diff --git a/app/containers/LoginServices.tsx b/app/containers/LoginServices.tsx index bf175dd70cd..aab5c889e2f 100644 --- a/app/containers/LoginServices.tsx +++ b/app/containers/LoginServices.tsx @@ -423,4 +423,4 @@ const mapStateToProps = (state: any) => ({ services: state.login.services }); -export default connect(mapStateToProps)(withTheme(LoginServices)); +export default connect(mapStateToProps)(withTheme(LoginServices)) as any; diff --git a/app/containers/MessageBox/EmojiKeyboard.tsx b/app/containers/MessageBox/EmojiKeyboard.tsx index bbb0e20ad5b..91acc45d107 100644 --- a/app/containers/MessageBox/EmojiKeyboard.tsx +++ b/app/containers/MessageBox/EmojiKeyboard.tsx @@ -13,7 +13,7 @@ interface IMessageBoxEmojiKeyboard { } export default class EmojiKeyboard extends React.PureComponent { - private readonly baseUrl: any; + private readonly baseUrl: string; constructor(props: IMessageBoxEmojiKeyboard) { super(props); diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index 047c128bdaf..8645a165c17 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -1124,4 +1124,4 @@ const dispatchToProps = { typing: (rid: any, status: any) => userTypingAction(rid, status) }; // @ts-ignore -export default connect(mapStateToProps, dispatchToProps, null, { forwardRef: true })(withActionSheet(MessageBox)); +export default connect(mapStateToProps, dispatchToProps, null, { forwardRef: true })(withActionSheet(MessageBox)) as any; diff --git a/app/stacks/MasterDetailStack/index.tsx b/app/stacks/MasterDetailStack/index.tsx index 5679561db4c..4cc25612507 100644 --- a/app/stacks/MasterDetailStack/index.tsx +++ b/app/stacks/MasterDetailStack/index.tsx @@ -96,6 +96,7 @@ const ChatsStackNavigator = React.memo(() => { const Drawer = createDrawerNavigator(); const DrawerNavigator = React.memo(() => ( } drawerType='permanent'> @@ -129,11 +130,7 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => { /> - + { component={ForwardLivechatView} options={ForwardLivechatView.navigationOptions} /> - - + + @@ -235,21 +224,13 @@ const ModalStackNavigator = React.memo(({ navigation }: INavigation) => { component={E2EEnterYourPasswordView} options={E2EEnterYourPasswordView.navigationOptions} /> - + - + { - + diff --git a/app/stacks/types.ts b/app/stacks/types.ts index 28d77592ab4..c9386d939c8 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -100,7 +100,7 @@ export type ChatsStackParamList = { title: string; data: IOptionsField[]; value?: any; // TODO: Change - onChangeText?: Function; + onChangeText?: ((text: string) => IOptionsField[]) | ((term?: string) => Promise); goBack?: boolean; onChangeValue: Function; }; diff --git a/app/views/PickerView.tsx b/app/views/PickerView.tsx index 570d8e4bda4..db2a7a265ab 100644 --- a/app/views/PickerView.tsx +++ b/app/views/PickerView.tsx @@ -55,7 +55,7 @@ const Item = React.memo(({ item, selected, onItemPress, theme }: IItem) => ( )); class PickerView extends React.PureComponent { - private onSearch?: (text: string) => IOptionsField[]; + private onSearch?: ((text: string) => IOptionsField[]) | ((term?: string | undefined) => Promise); static navigationOptions = ({ route }: IPickerViewProps) => ({ title: route.params?.title ?? I18n.t('Select_an_option') diff --git a/app/views/SidebarView/index.tsx b/app/views/SidebarView/index.tsx index d8cfa38cad1..c410f63dfb0 100644 --- a/app/views/SidebarView/index.tsx +++ b/app/views/SidebarView/index.tsx @@ -306,4 +306,4 @@ const mapStateToProps = (state: any) => ({ viewPrivilegedSettingPermission: state.permissions['view-privileged-setting'] }); -export default connect(mapStateToProps)(withTheme(Sidebar)); +export default connect(mapStateToProps)(withTheme(Sidebar)) as any; From 1a13d4486a62e91620d407bce29b3e32fe5bbddf Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Thu, 2 Dec 2021 11:58:20 -0400 Subject: [PATCH 22/23] Minor tweak --- app/containers/EmojiPicker/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/containers/EmojiPicker/index.tsx b/app/containers/EmojiPicker/index.tsx index 94d70e89da4..e59adf6e701 100644 --- a/app/containers/EmojiPicker/index.tsx +++ b/app/containers/EmojiPicker/index.tsx @@ -31,7 +31,7 @@ interface IEmojiPickerProps { customEmojis?: any; style: object; theme?: string; - onEmojiSelected?: (emoji: any) => void; + onEmojiSelected?: ((emoji: any) => void) | ((keyboardId: any, params?: any) => void); tabEmojiStyle?: object; } @@ -97,7 +97,7 @@ class EmojiPicker extends Component { const content = emoji; this._addFrequentlyUsed({ content, isCustom: false }); const shortname = `:${emoji}:`; - onEmojiSelected!(shortnameToUnicode(shortname)); + onEmojiSelected!(shortnameToUnicode(shortname), shortname); } } catch (e) { log(e); @@ -201,4 +201,4 @@ const mapStateToProps = (state: any) => ({ customEmojis: state.customEmojis }); -export default connect(mapStateToProps)(withTheme(EmojiPicker)) as any; +export default connect(mapStateToProps)(withTheme(EmojiPicker)); From f1b413c9e7d0b85d3ac7aac5234c9bba90b3c5a1 Mon Sep 17 00:00:00 2001 From: AlexAlexandre Date: Thu, 2 Dec 2021 14:41:22 -0300 Subject: [PATCH 23/23] chore: Minor tweak --- app/containers/EmojiPicker/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/containers/EmojiPicker/index.tsx b/app/containers/EmojiPicker/index.tsx index e59adf6e701..12217cf9521 100644 --- a/app/containers/EmojiPicker/index.tsx +++ b/app/containers/EmojiPicker/index.tsx @@ -201,4 +201,5 @@ const mapStateToProps = (state: any) => ({ customEmojis: state.customEmojis }); -export default connect(mapStateToProps)(withTheme(EmojiPicker)); +// TODO - remove this as any, at the new PR to fix the HOC erros +export default connect(mapStateToProps)(withTheme(EmojiPicker)) as any;