Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions app/presentation/DirectoryItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ interface IDirectoryItem {
rightLabel: string;
rid: string;
theme: string;
teamMain: boolean;
teamMain?: boolean;
}

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 All @@ -47,7 +47,7 @@ const DirectoryItem = ({
rid,
theme,
teamMain
}: IDirectoryItem) => (
}: IDirectoryItem): JSX.Element => (
<Touch onPress={onPress} style={{ backgroundColor: themes[theme].backgroundColor }} testID={testID} theme={theme}>
<View style={[styles.directoryItemContainer, styles.directoryItemButton, style]}>
<Avatar text={avatar} size={30} type={type} rid={rid} style={styles.directoryItemAvatar} />
Expand Down
1 change: 1 addition & 0 deletions app/utils/log/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default {
// DIRECTORY VIEW
DIRECTORY_SEARCH_USERS: 'directory_search_users',
DIRECTORY_SEARCH_CHANNELS: 'directory_search_channels',
DIRECTORY_SEARCH_TEAMS: 'directory_search_teams',

// NEW MESSAGE VIEW
NEW_MSG_CREATE_CHANNEL: 'new_msg_create_channel',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { PureComponent } from 'react';
import { Animated, Easing, Switch, Text, TouchableWithoutFeedback, View } from 'react-native';
import PropTypes from 'prop-types';

import Touch from '../../utils/touch';
import { CustomIcon } from '../../lib/Icons';
Expand All @@ -16,18 +15,20 @@ const ANIMATION_PROPS = {
useNativeDriver: true
};

export default class DirectoryOptions extends PureComponent {
static propTypes = {
type: PropTypes.string,
globalUsers: PropTypes.bool,
isFederationEnabled: PropTypes.bool,
close: PropTypes.func,
changeType: PropTypes.func,
toggleWorkspace: PropTypes.func,
theme: PropTypes.string
};
interface IDirectoryOptionsProps {
type: string;
globalUsers: boolean;
isFederationEnabled: boolean;
close: Function;
changeType: Function;
toggleWorkspace(): void;
theme: string;
}

export default class DirectoryOptions extends PureComponent<IDirectoryOptionsProps, any> {
private animatedValue: Animated.Value;

constructor(props) {
constructor(props: IDirectoryOptionsProps) {
super(props);
this.animatedValue = new Animated.Value(0);
}
Expand All @@ -47,7 +48,7 @@ export default class DirectoryOptions extends PureComponent {
}).start(() => close());
};

renderItem = itemType => {
renderItem = (itemType: string) => {
const { changeType, type: propType, theme } = this.props;
let text = 'Users';
let icon = 'user';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import { FlatList, Text, View } from 'react-native';
import { connect } from 'react-redux';

Expand All @@ -24,9 +23,22 @@ import { goRoom } from '../../utils/goRoom';
import styles from './styles';
import Options from './Options';

class DirectoryView extends React.Component {
static navigationOptions = ({ navigation, isMasterDetail }) => {
const options = {
interface IDirectoryViewProps {
navigation: object;
baseUrl: string;
isFederationEnabled: boolean;
user: {
id: string;
token: string;
};
theme: string;
directoryDefaultView: string;
isMasterDetail: boolean;
}

class DirectoryView extends React.Component<IDirectoryViewProps, any> {
static navigationOptions = ({ navigation, isMasterDetail }: any) => {
const options: any = {
title: I18n.t('Directory')
};
if (isMasterDetail) {
Expand All @@ -35,20 +47,7 @@ class DirectoryView extends React.Component {
return options;
};

static propTypes = {
navigation: PropTypes.object,
baseUrl: PropTypes.string,
isFederationEnabled: PropTypes.bool,
user: PropTypes.shape({
id: PropTypes.string,
token: PropTypes.string
}),
theme: PropTypes.string,
directoryDefaultView: PropTypes.string,
isMasterDetail: PropTypes.bool
};

constructor(props) {
constructor(props: IDirectoryViewProps) {
super(props);
this.state = {
data: [],
Expand All @@ -65,7 +64,7 @@ class DirectoryView extends React.Component {
this.load({});
}

onSearchChangeText = text => {
onSearchChangeText = (text: string) => {
this.setState({ text }, this.search);
};

Expand Down Expand Up @@ -115,7 +114,7 @@ class DirectoryView extends React.Component {
this.load({ newSearch: true });
};

changeType = type => {
changeType = (type: string) => {
this.setState({ type, data: [] }, () => this.search());

if (type === 'users') {
Expand All @@ -129,17 +128,17 @@ class DirectoryView extends React.Component {

toggleWorkspace = () => {
this.setState(
({ globalUsers }) => ({ globalUsers: !globalUsers, data: [] }),
({ globalUsers }: any) => ({ globalUsers: !globalUsers, data: [] }),
() => this.search()
);
};

toggleDropdown = () => {
this.setState(({ showOptionsDropdown }) => ({ showOptionsDropdown: !showOptionsDropdown }));
this.setState(({ showOptionsDropdown }: any) => ({ showOptionsDropdown: !showOptionsDropdown }));
};

goRoom = item => {
const { navigation, isMasterDetail } = this.props;
goRoom = (item: any) => {
const { navigation, isMasterDetail }: any = this.props;
if (isMasterDetail) {
navigation.navigate('DrawerNavigator');
} else {
Expand All @@ -148,7 +147,7 @@ class DirectoryView extends React.Component {
goRoom({ item, isMasterDetail });
};

onPressItem = async item => {
onPressItem = async (item: any) => {
const { type } = this.state;
if (type === 'users') {
const result = await RocketChat.createDirectMessage(item.username);
Expand Down Expand Up @@ -215,7 +214,7 @@ class DirectoryView extends React.Component {
);
};

renderItem = ({ item, index }) => {
renderItem = ({ item, index }: any) => {
const { data, type } = this.state;
const { baseUrl, user, theme } = this.props;

Expand Down Expand Up @@ -308,7 +307,7 @@ class DirectoryView extends React.Component {
};
}

const mapStateToProps = state => ({
const mapStateToProps = (state: any) => ({
baseUrl: state.server.server,
user: getUserSelector(state),
isFederationEnabled: state.settings.FEDERATION_Enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default StyleSheet.create({
top: 0
},
backdrop: {
// @ts-ignore
...StyleSheet.absoluteFill
},
dropdownContainerHeader: {
Expand Down