Skip to content
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Clipboard, Linking, Share } from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import FastImage from '@rocket.chat/react-native-fast-image';
import CookieManager from '@react-native-cookies/cookies';
import { StackNavigationProp } from '@react-navigation/stack';

import { logout as logoutAction } from '../../actions/login';
import { selectServerRequest as selectServerRequestAction } from '../../actions/server';
Expand All @@ -29,8 +29,25 @@ import database from '../../lib/database';
import { isFDroidBuild } from '../../constants/environment';
import { getUserSelector } from '../../selectors/login';

class SettingsView extends React.Component {
static navigationOptions = ({ navigation, isMasterDetail }) => ({
interface IProps {
navigation: StackNavigationProp<any>;
Comment thread
gerzonc marked this conversation as resolved.
Outdated
server: {
version: string;
server: string;
};
theme: string;
isMasterDetail: boolean;
logout: Function;
selectServerRequest: Function;
user: {
roles: [];
id: string;
};
appStart: Function;
}

class SettingsView extends React.Component<IProps, any> {
static navigationOptions = ({ navigation, isMasterDetail }: Partial<IProps>) => ({
headerLeft: () =>
isMasterDetail ? (
<HeaderButton.CloseModal navigation={navigation} testID='settings-view-close' />
Expand All @@ -40,20 +57,6 @@ class SettingsView extends React.Component {
title: I18n.t('Settings')
});

static propTypes = {
navigation: PropTypes.object,
server: PropTypes.object,
theme: PropTypes.string,
isMasterDetail: PropTypes.bool,
logout: PropTypes.func.isRequired,
selectServerRequest: PropTypes.func,
user: PropTypes.shape({
roles: PropTypes.array,
id: PropTypes.string
}),
appStart: PropTypes.func
};

checkCookiesAndLogout = async () => {
const { logout, user } = this.props;
const db = database.servers;
Expand Down Expand Up @@ -93,6 +96,7 @@ class SettingsView extends React.Component {

handleClearCache = () => {
logEvent(events.SE_CLEAR_LOCAL_SERVER_CACHE);
/* @ts-ignore */
showConfirmationAlert({
message: I18n.t('This_will_clear_all_your_offline_data'),
confirmationText: I18n.t('Clear'),
Expand All @@ -112,7 +116,8 @@ class SettingsView extends React.Component {
});
};

navigateToScreen = screen => {
navigateToScreen = (screen: string) => {
/* @ts-ignore */
logEvent(events[`SE_GO_${screen.replace('View', '').toUpperCase()}`]);
const { navigation } = this.props;
navigation.navigate(screen);
Expand Down Expand Up @@ -160,7 +165,7 @@ class SettingsView extends React.Component {
this.saveToClipboard(getReadableVersion);
};

saveToClipboard = async content => {
saveToClipboard = async (content: string) => {
await Clipboard.setString(content);
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
};
Expand Down Expand Up @@ -291,16 +296,16 @@ class SettingsView extends React.Component {
}
}

const mapStateToProps = state => ({
const mapStateToProps = (state: any) => ({
server: state.server,
user: getUserSelector(state),
isMasterDetail: state.app.isMasterDetail
});

const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = (dispatch: any) => ({
logout: () => dispatch(logoutAction()),
selectServerRequest: params => dispatch(selectServerRequestAction(params)),
appStart: params => dispatch(appStartAction(params))
selectServerRequest: (params: any) => dispatch(selectServerRequestAction(params)),
appStart: (params: any) => dispatch(appStartAction(params))
});

export default connect(mapStateToProps, mapDispatchToProps)(withTheme(SettingsView));