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
2 changes: 1 addition & 1 deletion app/containers/MessageBox/EmojiKeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class EmojiKeyboard extends React.PureComponent {
constructor(props) {
super(props);
const state = store.getState();
this.baseUrl = state.settings.Site_Url || state.server ? state.server.server : '';
this.baseUrl = state.server.server;
}

onEmojiSelected = (emoji) => {
Expand Down
2 changes: 1 addition & 1 deletion app/containers/MessageBox/ReplyPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ReplyPreview.propTypes = {
const mapStateToProps = state => ({
useMarkdown: state.markdown.useMarkdown,
Message_TimeFormat: state.settings.Message_TimeFormat,
baseUrl: state.settings.Site_Url || state.server ? state.server.server : ''
baseUrl: state.server.server
});

export default connect(mapStateToProps)(ReplyPreview);
9 changes: 3 additions & 6 deletions app/containers/MessageBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
} from './constants';
import CommandsPreview from './CommandsPreview';
import { Review } from '../../utils/review';
import { getUserSelector } from '../../selectors/login';

const imagePickerConfig = {
cropping: true,
Expand Down Expand Up @@ -881,13 +882,9 @@ class MessageBox extends Component {
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
baseUrl: state.server.server,
threadsEnabled: state.settings.Threads_enabled,
user: {
id: state.login.user && state.login.user.id,
username: state.login.user && state.login.user.username,
token: state.login.user && state.login.user.token
},
user: getUserSelector(state),
FileUpload_MediaTypeWhiteList: state.settings.FileUpload_MediaTypeWhiteList,
FileUpload_MaxFileSize: state.settings.FileUpload_MaxFileSize
});
Expand Down
6 changes: 1 addition & 5 deletions app/lib/methods/sendFileMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ export async function cancelUpload(item) {
export function sendFileMessage(rid, fileInfo, tmid, server, user) {
return new Promise(async(resolve, reject) => {
try {
const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers');
const serverInfo = await serversCollection.find(server);
const { id: Site_Url } = serverInfo;
const { id, token } = user;

const uploadUrl = `${ Site_Url }/api/v1/rooms.upload/${ rid }`;
const uploadUrl = `${ server }/api/v1/rooms.upload/${ rid }`;

const xhr = new XMLHttpRequest();
const formData = new FormData();
Expand Down
11 changes: 5 additions & 6 deletions app/notifications/inApp/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { removeNotification as removeNotificationAction } from '../../actions/no
import sharedStyles from '../../views/Styles';
import { ROW_HEIGHT } from '../../presentation/RoomItem';
import { withTheme } from '../../theme';
import { getUserSelector } from '../../selectors/login';

const AVATAR_SIZE = 48;
const ANIMATION_DURATION = 300;
Expand Down Expand Up @@ -72,8 +73,7 @@ class NotificationBadge extends React.Component {
static propTypes = {
navigation: PropTypes.object,
baseUrl: PropTypes.string,
token: PropTypes.string,
userId: PropTypes.string,
user: PropTypes.object,
notification: PropTypes.object,
window: PropTypes.object,
removeNotification: PropTypes.func,
Expand Down Expand Up @@ -173,7 +173,7 @@ class NotificationBadge extends React.Component {

render() {
const {
baseUrl, token, userId, notification, window, theme
baseUrl, user: { id: userId, token }, notification, window, theme
} = this.props;
const { message, payload } = notification;
const { type } = payload;
Expand Down Expand Up @@ -227,9 +227,8 @@ class NotificationBadge extends React.Component {
}

const mapStateToProps = state => ({
userId: state.login.user && state.login.user.id,
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
token: state.login.user && state.login.user.token,
user: getUserSelector(state),
baseUrl: state.server.server,
notification: state.notification
});

Expand Down
8 changes: 8 additions & 0 deletions app/selectors/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createSelector } from 'reselect';

const getUser = state => state.login.user || {};

export const getUserSelector = createSelector(
[getUser],
user => user
);
11 changes: 6 additions & 5 deletions app/views/AdminPanelView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import styles from '../Styles';
import { themedHeader } from '../../utils/navigation';
import { withTheme } from '../../theme';
import { themes } from '../../constants/colors';
import { getUserSelector } from '../../selectors/login';

class AdminPanelView extends React.Component {
static navigationOptions = ({ navigation, screenProps }) => ({
Expand All @@ -21,12 +22,12 @@ class AdminPanelView extends React.Component {

static propTypes = {
baseUrl: PropTypes.string,
authToken: PropTypes.string,
token: PropTypes.string,
theme: PropTypes.string
}

render() {
const { baseUrl, authToken, theme } = this.props;
const { baseUrl, token, theme } = this.props;
if (!baseUrl) {
return null;
}
Expand All @@ -35,16 +36,16 @@ class AdminPanelView extends React.Component {
<StatusBar theme={theme} />
<WebView
source={{ uri: `${ baseUrl }/admin/info?layout=embedded` }}
injectedJavaScript={`Meteor.loginWithToken('${ authToken }', function() { })`}
injectedJavaScript={`Meteor.loginWithToken('${ token }', function() { })`}
/>
</SafeAreaView>
);
}
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
authToken: state.login.user && state.login.user.token
baseUrl: state.server.server,
token: getUserSelector(state).token
});

export default connect(mapStateToProps)(withTheme(AdminPanelView));
8 changes: 3 additions & 5 deletions app/views/AttachmentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { formatAttachmentUrl } from '../lib/utils';
import RCActivityIndicator from '../containers/ActivityIndicator';
import { SaveButton, CloseModalButton } from '../containers/HeaderButton';
import { isAndroid } from '../utils/deviceInfo';
import { getUserSelector } from '../selectors/login';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -142,11 +143,8 @@ class AttachmentView extends React.Component {
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
user: {
id: state.login.user && state.login.user.id,
token: state.login.user && state.login.user.token
}
baseUrl: state.server.server,
user: getUserSelector(state)
});

export default connect(mapStateToProps)(withTheme(AttachmentView));
8 changes: 3 additions & 5 deletions app/views/CreateChannelView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { SWITCH_TRACK_COLOR, themes } from '../constants/colors';
import { withTheme } from '../theme';
import { themedHeader } from '../utils/navigation';
import { Review } from '../utils/review';
import { getUserSelector } from '../selectors/login';

const styles = StyleSheet.create({
container: {
Expand Down Expand Up @@ -365,16 +366,13 @@ class CreateChannelView extends React.Component {
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
baseUrl: state.server.server,
error: state.createChannel.error,
failure: state.createChannel.failure,
isFetching: state.createChannel.isFetching,
result: state.createChannel.result,
users: state.selectedUsers.users,
user: {
id: state.login.user && state.login.user.id,
token: state.login.user && state.login.user.token
}
user: getUserSelector(state)
});

const mapDispatchToProps = dispatch => ({
Expand Down
8 changes: 3 additions & 5 deletions app/views/DirectoryView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { withTheme } from '../../theme';
import { themes } from '../../constants/colors';
import styles from './styles';
import { themedHeader } from '../../utils/navigation';
import { getUserSelector } from '../../selectors/login';

class DirectoryView extends React.Component {
static navigationOptions = ({ navigation, screenProps }) => {
Expand Down Expand Up @@ -253,11 +254,8 @@ class DirectoryView extends React.Component {
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
user: {
id: state.login.user && state.login.user.id,
token: state.login.user && state.login.user.token
},
baseUrl: state.server.server,
user: getUserSelector(state),
isFederationEnabled: state.settings.FEDERATION_Enabled
});

Expand Down
3 changes: 2 additions & 1 deletion app/views/LanguageView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Separator from '../../containers/Separator';
import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import { themedHeader } from '../../utils/navigation';
import { getUserSelector } from '../../selectors/login';

const LANGUAGES = [
{
Expand Down Expand Up @@ -185,7 +186,7 @@ class LanguageView extends React.Component {
}

const mapStateToProps = state => ({
userLanguage: state.login.user && state.login.user.language
userLanguage: getUserSelector(state).language
});

const mapDispatchToProps = dispatch => ({
Expand Down
9 changes: 3 additions & 6 deletions app/views/MessagesView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import { withSplit } from '../../split';
import { themedHeader } from '../../utils/navigation';
import { getUserSelector } from '../../selectors/login';

const ACTION_INDEX = 0;
const CANCEL_INDEX = 1;
Expand Down Expand Up @@ -306,12 +307,8 @@ class MessagesView extends React.Component {
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
user: {
id: state.login.user && state.login.user.id,
username: state.login.user && state.login.user.username,
token: state.login.user && state.login.user.token
},
baseUrl: state.server.server,
user: getUserSelector(state),
customEmojis: state.customEmojis
});

Expand Down
8 changes: 3 additions & 5 deletions app/views/NewMessageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import StatusBar from '../containers/StatusBar';
import { themes } from '../constants/colors';
import { withTheme } from '../theme';
import { themedHeader } from '../utils/navigation';
import { getUserSelector } from '../selectors/login';

const styles = StyleSheet.create({
safeAreaView: {
Expand Down Expand Up @@ -227,11 +228,8 @@ class NewMessageView extends React.Component {
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
user: {
id: state.login.user && state.login.user.id,
token: state.login.user && state.login.user.token
}
baseUrl: state.server.server,
user: getUserSelector(state)
});

export default connect(mapStateToProps)(withTheme(NewMessageView));
12 changes: 3 additions & 9 deletions app/views/ProfileView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import StatusBar from '../../containers/StatusBar';
import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import { themedHeader } from '../../utils/navigation';
import { getUserSelector } from '../../selectors/login';

class ProfileView extends React.Component {
static navigationOptions = ({ navigation, screenProps }) => ({
Expand Down Expand Up @@ -497,16 +498,9 @@ class ProfileView extends React.Component {
}

const mapStateToProps = state => ({
user: {
id: state.login.user && state.login.user.id,
name: state.login.user && state.login.user.name,
username: state.login.user && state.login.user.username,
customFields: state.login.user && state.login.user.customFields,
emails: state.login.user && state.login.user.emails,
token: state.login.user && state.login.user.token
},
user: getUserSelector(state),
Accounts_CustomFields: state.settings.Accounts_CustomFields,
baseUrl: state.settings.Site_Url || state.server ? state.server.server : ''
baseUrl: state.server.server
});

const mapDispatchToProps = dispatch => ({
Expand Down
11 changes: 5 additions & 6 deletions app/views/ReadReceiptView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import StatusBar from '../../containers/StatusBar';
import { withTheme } from '../../theme';
import { themedHeader } from '../../utils/navigation';
import { themes } from '../../constants/colors';
import { getUserSelector } from '../../selectors/login';

class ReadReceiptView extends React.Component {
static navigationOptions = ({ screenProps }) => ({
Expand All @@ -26,8 +27,7 @@ class ReadReceiptView extends React.Component {
navigation: PropTypes.object,
Message_TimeFormat: PropTypes.string,
baseUrl: PropTypes.string,
userId: PropTypes.string,
token: PropTypes.string,
user: PropTypes.object,
theme: PropTypes.string
}

Expand Down Expand Up @@ -92,7 +92,7 @@ class ReadReceiptView extends React.Component {

renderItem = ({ item }) => {
const {
Message_TimeFormat, userId, baseUrl, token, theme
Message_TimeFormat, user: { id: userId, token }, baseUrl, theme
} = this.props;
const time = moment(item.ts).format(Message_TimeFormat);
return (
Expand Down Expand Up @@ -167,9 +167,8 @@ class ReadReceiptView extends React.Component {

const mapStateToProps = state => ({
Message_TimeFormat: state.settings.Message_TimeFormat,
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
userId: state.login.user && state.login.user.id,
token: state.login.user && state.login.user.token
baseUrl: state.server.server,
user: getUserSelector(state)
});

export default connect(mapStateToProps)(withTheme(ReadReceiptView));
8 changes: 3 additions & 5 deletions app/views/RoomActionsView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import { themedHeader } from '../../utils/navigation';
import { CloseModalButton } from '../../containers/HeaderButton';
import { getUserSelector } from '../../selectors/login';

class RoomActionsView extends React.Component {
static navigationOptions = ({ navigation, screenProps }) => {
Expand Down Expand Up @@ -523,11 +524,8 @@ class RoomActionsView extends React.Component {
}

const mapStateToProps = state => ({
user: {
id: state.login.user && state.login.user.id,
token: state.login.user && state.login.user.token
},
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
user: getUserSelector(state),
baseUrl: state.server.server,
jitsiEnabled: state.settings.Jitsi_Enabled || false
});

Expand Down
8 changes: 3 additions & 5 deletions app/views/RoomInfoView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import log from '../../utils/log';
import { themes } from '../../constants/colors';
import { withTheme } from '../../theme';
import { themedHeader } from '../../utils/navigation';
import { getUserSelector } from '../../selectors/login';

const PERMISSION_EDIT_ROOM = 'edit-room';

Expand Down Expand Up @@ -309,11 +310,8 @@ class RoomInfoView extends React.Component {
}

const mapStateToProps = state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
user: {
id: state.login.user && state.login.user.id,
token: state.login.user && state.login.user.token
},
baseUrl: state.server.server,
user: getUserSelector(state),
Message_TimeFormat: state.settings.Message_TimeFormat
});

Expand Down
Loading