Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/externalModules.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ declare module '@rocket.chat/ui-kit';
declare module '@rocket.chat/sdk';
declare module 'react-native-config-reader';
declare module 'react-native-keycommands';
declare module 'react-native-mime-types';
10 changes: 5 additions & 5 deletions app/presentation/DirectoryItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { themes } from '../../constants/colors';
export { ROW_HEIGHT };

interface IDirectoryItemLabel {
text: string;
text?: string;
theme: string;
}

Expand All @@ -21,9 +21,9 @@ interface IDirectoryItem {
type: string;
onPress(): void;
testID: string;
style: any;
rightLabel: string;
rid: string;
style?: any;
Comment thread
reinaldonetof marked this conversation as resolved.
Outdated
rightLabel?: string;
rid?: string;
theme: string;
teamMain?: boolean;
}
Expand All @@ -32,7 +32,7 @@ const DirectoryItemLabel = React.memo(({ text, theme }: IDirectoryItemLabel) =>
if (!text) {
return null;
}
return <Text style={[styles.directoryItemLabel, { color: themes[theme!].auxiliaryText }]}>{text}</Text>;
return <Text style={[styles.directoryItemLabel, { color: themes[theme].auxiliaryText }]}>{text}</Text>;
});

const DirectoryItem = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import PropTypes from 'prop-types';

import TextInput from '../../../presentation/TextInput';
import I18n from '../../../i18n';
Expand All @@ -24,7 +23,13 @@ const styles = StyleSheet.create({
}
});

const Header = React.memo(({ searching, onChangeSearchText, theme }) => {
interface IHeader {
searching: boolean;
Comment thread
reinaldonetof marked this conversation as resolved.
Outdated
onChangeSearchText(text: string): void;

@gerzonc gerzonc Nov 2, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always have my doubts on this case if we should just rename the function (so we can just extend TextInputProps) or use onChangeSearchText?: TextInputProps['onChangeText'] in order to keep the types as the component actually receives (of course, we know it's a function that takes text: string as param and returns void, but that doesn't mean it won't change in the future). We should keep this as future proof as possible, so either you can rename onChangeSearchText to onChangeText and make the interface extend TextInputProps or make it onChangeSearchText?: TextInputProps['onChangeText']

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme: string;
}

const Header = React.memo(({ searching, onChangeSearchText, theme }: IHeader) => {
const titleColorStyle = { color: themes[theme].headerTintColor };
const isLight = theme === 'light';
if (searching) {
Expand All @@ -43,10 +48,4 @@ const Header = React.memo(({ searching, onChangeSearchText, theme }) => {
return <Text style={[styles.title, titleColorStyle]}>{I18n.t('Send_to')}</Text>;
});

Header.propTypes = {
searching: PropTypes.bool,
onChangeSearchText: PropTypes.func,
theme: PropTypes.string
};

export default Header;
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { Keyboard, StyleSheet, View } from 'react-native';
import ShareExtension from 'rn-extensions-share';

Expand All @@ -16,10 +15,18 @@ const styles = StyleSheet.create({
}
});

const Header = React.memo(({ searching, onChangeSearchText, initSearch, cancelSearch, theme }) => {
interface IHeader {
searching: boolean;
Comment thread
reinaldonetof marked this conversation as resolved.
Outdated
onChangeSearchText(text: string): void;
Comment thread
reinaldonetof marked this conversation as resolved.
Outdated
initSearch: Function;
cancelSearch: Function;
theme: string;
}

const Header = React.memo(({ searching, onChangeSearchText, initSearch, cancelSearch, theme }: IHeader) => {
const [text, setText] = useState('');

const onChangeText = searchText => {
const onChangeText = (searchText: string) => {
onChangeSearchText(searchText);
setText(searchText);
};
Expand Down Expand Up @@ -59,12 +66,4 @@ const Header = React.memo(({ searching, onChangeSearchText, initSearch, cancelSe
);
});

Header.propTypes = {
searching: PropTypes.bool,
onChangeSearchText: PropTypes.func,
initSearch: PropTypes.func,
cancelSearch: PropTypes.func,
theme: PropTypes.string
};

export default Header;
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import React from 'react';
import PropTypes from 'prop-types';

// @ts-ignore
// eslint-disable-next-line import/extensions,import/no-unresolved
Comment thread
gerzonc marked this conversation as resolved.
Outdated
import Header from './Header';

const ShareListHeader = React.memo(({ searching, initSearch, cancelSearch, search, theme }) => {
const onSearchChangeText = text => {
interface IShareListHeader {
searching: boolean;
initSearch?: () => void;
cancelSearch?: () => void;
search(text: string): void;
theme: string;
}
Comment thread
reinaldonetof marked this conversation as resolved.
Outdated

const ShareListHeader = React.memo(({ searching, initSearch, cancelSearch, search, theme }: IShareListHeader) => {
const onSearchChangeText = (text: string) => {
search(text.trim());
};

Expand All @@ -19,12 +28,4 @@ const ShareListHeader = React.memo(({ searching, initSearch, cancelSearch, searc
);
});

ShareListHeader.propTypes = {
searching: PropTypes.bool,
initSearch: PropTypes.func,
cancelSearch: PropTypes.func,
search: PropTypes.func,
theme: PropTypes.string
};

export default ShareListHeader;
Loading