Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
6243b68
Try to fix performance
djorkaeffalexandre Jul 19, 2019
b043f9a
Add slice to fix crash memory
djorkaeffalexandre Jul 19, 2019
df66504
Remove sort and group by type
djorkaeffalexandre Jul 19, 2019
2346f57
Remove slice
djorkaeffalexandre Jul 19, 2019
796dea4
Fix memory on search
djorkaeffalexandre Jul 19, 2019
92ed265
Update code
djorkaeffalexandre Jul 19, 2019
68a7e24
Minor fixes
djorkaeffalexandre Jul 19, 2019
f2f83d8
Add border bottom to flatlist content
djorkaeffalexandre Jul 19, 2019
818dfb4
Add cancel button to search
djorkaeffalexandre Jul 20, 2019
59d90d0
Remove unnecessary socket
djorkaeffalexandre Jul 20, 2019
c943f88
Add loading while get subscriptions
djorkaeffalexandre Jul 20, 2019
fc171b6
Fix can upload file on Share Extension
djorkaeffalexandre Jul 22, 2019
6174761
Allow change server on file not allowed
djorkaeffalexandre Jul 22, 2019
4913d9b
Fix loading if error on upload media
djorkaeffalexandre Jul 22, 2019
356e7be
Remove debounce
djorkaeffalexandre Jul 22, 2019
95b7395
Fix infinity loading
djorkaeffalexandre Jul 22, 2019
6d3f6b6
Fix cancel button translate
djorkaeffalexandre Jul 22, 2019
662225d
Fix error on get userId - Share Extension
djorkaeffalexandre Jul 22, 2019
377edac
Fix share message
djorkaeffalexandre Jul 22, 2019
a88b811
Improve share extension init
djorkaeffalexandre Jul 22, 2019
7de1e90
Update code
djorkaeffalexandre Jul 22, 2019
22a07aa
Fix login sdk
djorkaeffalexandre Jul 22, 2019
5c8c3d8
Add search on header
djorkaeffalexandre Jul 22, 2019
0c34978
Fix padding on notch devices
djorkaeffalexandre Jul 22, 2019
c9b467a
Fix search after click on item
djorkaeffalexandre Jul 22, 2019
125acfd
Improve clear search
djorkaeffalexandre Jul 22, 2019
71092d6
Update schemaVersion
djorkaeffalexandre Jul 22, 2019
fb4a4b9
Refactor header share list
djorkaeffalexandre Jul 22, 2019
5688a8f
Improve setSearch
djorkaeffalexandre Jul 22, 2019
9070afa
Remove react-native-iphone-x-helper
djorkaeffalexandre Jul 22, 2019
b50721f
Improve search
djorkaeffalexandre Jul 22, 2019
9d6b008
Adjust some styles
djorkaeffalexandre Jul 22, 2019
9196270
Merge branch 'develop' into fix.share-extension-performance
diegolmello Jul 23, 2019
a7faf45
Change deployment target & bump version & change device compatibility
djorkaeffalexandre Jul 23, 2019
c0f3aee
Merge branch 'fix.share-extension-performance' of https://github.com/…
djorkaeffalexandre Jul 23, 2019
08d50be
Upgrade rn-extension-share
djorkaeffalexandre Jul 24, 2019
027c3b4
If there's no current token, show OutsideStack
diegolmello Jul 24, 2019
479020e
Missing translation
diegolmello Jul 24, 2019
ee7b304
Change from "Select channels" to "Send to..."
diegolmello Jul 24, 2019
46d0ef6
Enabled `canSend` as default
diegolmello Jul 24, 2019
4872bfa
Increase server icon size to align server label with channels labels
diegolmello Jul 24, 2019
15ce435
Android search header as React.memo
diegolmello Jul 24, 2019
f402ab5
Cancel search on Android back press
diegolmello Jul 24, 2019
aaa6576
Refactor
diegolmello Jul 24, 2019
a67307e
StatusBar
diegolmello Jul 24, 2019
0d520c4
Fix server change
diegolmello Jul 24, 2019
791ead2
Migrate Share Extension methods to external classes because android r…
djorkaeffalexandre Jul 25, 2019
04fcd0c
Merge
djorkaeffalexandre Jul 25, 2019
20c1918
Fix send file message
djorkaeffalexandre Jul 25, 2019
a91b191
Improve code
djorkaeffalexandre Jul 25, 2019
d0d0b81
Fix multiple logins android
djorkaeffalexandre Jul 26, 2019
6b7bc65
Change params to sendMessage
djorkaeffalexandre Jul 26, 2019
9e06611
Change params to sendFileMessage
djorkaeffalexandre Jul 26, 2019
5cba5d9
Fix problem on sendFileMessage
djorkaeffalexandre Jul 26, 2019
294a139
Fix file size
djorkaeffalexandre Jul 26, 2019
616dc7d
Change react-native-realm-path to podfile
djorkaeffalexandre Jul 26, 2019
c159f27
Change rn-extensions-share to Podfile
djorkaeffalexandre Jul 26, 2019
b018644
Upgrade rn-extensions-share
djorkaeffalexandre Jul 26, 2019
57c94a2
Fix error on canUploadFile
djorkaeffalexandre Jul 27, 2019
54c7afa
Improve code
djorkaeffalexandre Jul 27, 2019
583d18c
Fix error when you try to upload a invalid file
djorkaeffalexandre Jul 27, 2019
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
5 changes: 5 additions & 0 deletions app/actions/actionsTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const LOGIN = createRequestTypes('LOGIN', [
'SET_SERVICES',
'SET_PREFERENCE'
]);
export const SHARE = createRequestTypes('SHARE', [
'SELECT_SERVER',
'SET_USER',
'SET_SERVER_INFO'
]);
export const USER = createRequestTypes('USER', ['SET']);
export const ROOMS = createRequestTypes('ROOMS', [
...defaultTypes,
Expand Down
15 changes: 15 additions & 0 deletions app/actions/share.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { SHARE } from './actionsTypes';

export function shareSelectServer(server) {
return {
type: SHARE.SELECT_SERVER,
server
};
}

export function shareSetUser(user) {
return {
type: SHARE.SET_USER,
user
};
}
3 changes: 2 additions & 1 deletion app/containers/HeaderButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import HeaderButtons, { HeaderButton, Item } from 'react-navigation-header-butto
import { CustomIcon } from '../lib/Icons';
import { isIOS } from '../utils/deviceInfo';
import { COLOR_PRIMARY, COLOR_WHITE } from '../constants/colors';
import I18n from '../i18n';

const color = isIOS ? COLOR_PRIMARY : COLOR_WHITE;
export const headerIconSize = 23;
Expand Down Expand Up @@ -35,7 +36,7 @@ export const CloseModalButton = React.memo(({ navigation, testID }) => (
export const CloseShareExtensionButton = React.memo(({ onPress, testID }) => (
<CustomHeaderButtons left>
{isIOS
? <Item title='cancel' onPress={onPress} testID={testID} />
? <Item title={I18n.t('Cancel')} onPress={onPress} testID={testID} />
: <Item title='close' iconName='cross' onPress={onPress} testID={testID} />
}
</CustomHeaderButtons>
Expand Down
12 changes: 8 additions & 4 deletions app/containers/MessageBox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ class MessageBox extends Component {
}

sendMediaMessage = async(file) => {
const { rid, tmid } = this.props;
const {
rid, tmid, baseUrl: server, user
} = this.props;
this.setState({ file: { isVisible: false } });
const fileInfo = {
name: file.name,
Expand All @@ -500,7 +502,7 @@ class MessageBox extends Component {
path: file.path
};
try {
await RocketChat.sendFileMessage(rid, fileInfo, tmid);
await RocketChat.sendFileMessage(rid, fileInfo, tmid, server, user);
} catch (e) {
log('err_send_media_message', e);
}
Expand Down Expand Up @@ -602,14 +604,16 @@ class MessageBox extends Component {
}

finishAudioMessage = async(fileInfo) => {
const { rid, tmid } = this.props;
const {
rid, tmid, baseUrl: server, user
} = this.props;

this.setState({
recording: false
});
if (fileInfo) {
try {
await RocketChat.sendFileMessage(rid, fileInfo, tmid);
await RocketChat.sendFileMessage(rid, fileInfo, tmid, server, user);
} catch (e) {
if (e && e.error === 'error-file-too-large') {
return Alert.alert(I18n.t(e.error));
Expand Down
35 changes: 31 additions & 4 deletions app/containers/SearchBox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react';
import { View, StyleSheet, TextInput } from 'react-native';
import {
View, StyleSheet, TextInput, Text
} from 'react-native';
import PropTypes from 'prop-types';
import Touchable from 'react-native-platform-touchable';

import I18n from '../i18n';
import { isIOS } from '../utils/deviceInfo';
Expand All @@ -9,7 +12,10 @@ import sharedStyles from '../views/Styles';

const styles = StyleSheet.create({
container: {
backgroundColor: isIOS ? '#F7F8FA' : '#54585E'
backgroundColor: isIOS ? '#F7F8FA' : '#54585E',
flexDirection: 'row',
alignItems: 'center',
flex: 1
},
searchBox: {
alignItems: 'center',
Expand All @@ -21,7 +27,8 @@ const styles = StyleSheet.create({
height: 36,
margin: 16,
marginVertical: 10,
paddingHorizontal: 10
paddingHorizontal: 10,
flex: 1
},
input: {
color: '#8E8E93',
Expand All @@ -31,10 +38,26 @@ const styles = StyleSheet.create({
paddingTop: 0,
paddingBottom: 0,
...sharedStyles.textRegular
},
cancel: {
marginRight: 10
},
cancelText: {
...sharedStyles.textRegular,
...sharedStyles.textColorHeaderBack,
fontSize: 17
}
});

const SearchBox = ({ onChangeText, onSubmitEditing, testID }) => (
const CancelButton = onCancelPress => (
<Touchable onPress={onCancelPress} style={styles.cancel}>
<Text style={styles.cancelText}>{I18n.t('Cancel')}</Text>
</Touchable>
);

const SearchBox = ({
onChangeText, onSubmitEditing, testID, hasCancel, onCancelPress, ...props
}) => (
<View style={styles.container}>
<View style={styles.searchBox}>
<CustomIcon name='magnifier' size={14} color='#8E8E93' />
Expand All @@ -50,14 +73,18 @@ const SearchBox = ({ onChangeText, onSubmitEditing, testID }) => (
underlineColorAndroid='transparent'
onChangeText={onChangeText}
onSubmitEditing={onSubmitEditing}
{...props}
/>
</View>
{ hasCancel ? CancelButton(onCancelPress) : null }
</View>
);

SearchBox.propTypes = {
onChangeText: PropTypes.func.isRequired,
onSubmitEditing: PropTypes.func,
hasCancel: PropTypes.bool,
onCancelPress: PropTypes.func,
testID: PropTypes.string
};

Expand Down
2 changes: 1 addition & 1 deletion app/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ export default {
Search_global_users: 'Search for global users',
Search_global_users_description: 'If you turn-on, you can search for any user from others companies or servers.',
Select_Avatar: 'Select Avatar',
Select_Channels: 'Select Channels',
Select_Server: 'Select Server',
Select_Users: 'Select Users',
Send: 'Send',
Send_audio_message: 'Send audio message',
Send_crash_report: 'Send crash report',
Send_message: 'Send message',
Send_to: 'Send to...',
Sent_an_attachment: 'Sent an attachment',
Server: 'Server',
Servers: 'Servers',
Expand Down
3 changes: 2 additions & 1 deletion app/i18n/locales/pt-BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,12 @@ export default {
Search_global_users: 'Busca por usuários globais',
Search_global_users_description: 'Caso ativado, busca por usuários de outras empresas ou servidores.',
Select_Avatar: 'Selecionar Avatar',
Select_Channels: 'Selecionar Canais',
Select_Server: 'Selecionar Servidor',
Select_Users: 'Selecionar Usuários',
Send: 'Enviar',
Send_audio_message: 'Enviar mensagem de áudio',
Send_message: 'Enviar mensagem',
Send_to: 'Enviar para...',
Sent_an_attachment: 'Enviou um anexo',
Server: 'Servidor',
Set_username_subtitle: 'O usuário é utilizado para permitir que você seja mencionado em mensagens',
Expand Down Expand Up @@ -383,5 +383,6 @@ export default {
you_were_mentioned: 'você foi mencionado',
you: 'você',
You: 'Você',
You_need_to_access_at_least_one_RocketChat_server_to_share_something: 'Você precisa acessar ao menos um servidor Rocket.Chat para compartilhar.',
You_will_not_be_able_to_recover_this_message: 'Você não será capaz de recuperar essa mensagem!'
};
21 changes: 21 additions & 0 deletions app/lib/ShareNavigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NavigationActions } from 'react-navigation';

let _shareNavigator;

function setTopLevelNavigator(navigatorRef) {
_shareNavigator = navigatorRef;
}

function navigate(routeName, params) {
_shareNavigator.dispatch(
NavigationActions.navigate({
routeName,
params
})
);
}

export default {
navigate,
setTopLevelNavigator
};
9 changes: 9 additions & 0 deletions app/lib/methods/getSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ export default async function() {
if (setting._id === 'Site_Name') {
updateServer.call(this, { name: setting.valueAsString });
}
if (setting._id === 'UI_Use_Real_Name') {
updateServer.call(this, { useRealName: setting.valueAsBoolean });
}
if (setting._id === 'FileUpload_MediaTypeWhiteList') {
updateServer.call(this, { FileUpload_MediaTypeWhiteList: setting.valueAsString });
}
if (setting._id === 'FileUpload_MaxFileSize') {
updateServer.call(this, { FileUpload_MaxFileSize: setting.valueAsNumber });
}
})
)
);
Expand Down
8 changes: 4 additions & 4 deletions app/lib/methods/sendFileMessage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import reduxStore from '../createStore';
import database from '../realm';
import log from '../../utils/log';

Expand All @@ -23,11 +22,12 @@ export function cancelUpload(path) {
}
}

export function sendFileMessage(rid, fileInfo, tmid) {
export function sendFileMessage(rid, fileInfo, tmid, server, user) {
return new Promise((resolve, reject) => {
try {
const { FileUpload_MaxFileSize, Site_Url } = reduxStore.getState().settings;
const { id, token } = reduxStore.getState().login.user;
const { serversDB } = database.databases;
const { FileUpload_MaxFileSize, id: Site_Url } = serversDB.objectForPrimaryKey('servers', server);
const { id, token } = user;

// -1 maxFileSize means there is no limit
if (FileUpload_MaxFileSize > -1 && fileInfo.size > FileUpload_MaxFileSize) {
Expand Down
12 changes: 6 additions & 6 deletions app/lib/methods/sendMessage.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import messagesStatus from '../../constants/messagesStatus';
import buildMessage from './helpers/buildMessage';
import database from '../realm';
import reduxStore from '../createStore';
import log from '../../utils/log';
import random from '../../utils/random';

export const getMessage = (rid, msg = '', tmid) => {
export const getMessage = (rid, msg = '', tmid, user) => {
const _id = random(17);
const { id, username } = user;
const message = {
_id,
rid,
Expand All @@ -16,8 +16,8 @@ export const getMessage = (rid, msg = '', tmid) => {
_updatedAt: new Date(),
status: messagesStatus.TEMP,
u: {
_id: reduxStore.getState().login.user.id || '1',
username: reduxStore.getState().login.user.username
_id: id || '1',
username
}
};
try {
Expand All @@ -43,9 +43,9 @@ export async function sendMessageCall(message) {
return data;
}

export default async function(rid, msg, tmid) {
export default async function(rid, msg, tmid, user) {
try {
const message = getMessage(rid, msg, tmid);
const message = getMessage(rid, msg, tmid, user);
const [room] = database.objects('subscriptions').filtered('rid == $0', rid);

if (room) {
Expand Down
5 changes: 4 additions & 1 deletion app/lib/realm.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const serversSchema = {
id: 'string',
name: { type: 'string', optional: true },
iconURL: { type: 'string', optional: true },
useRealName: { type: 'bool', optional: true },
FileUpload_MediaTypeWhiteList: { type: 'string', optional: true },
FileUpload_MaxFileSize: { type: 'int', optional: true },
roomsUpdatedAt: { type: 'date', optional: true },
version: 'string?'
}
Expand Down Expand Up @@ -414,7 +417,7 @@ class DB {
userSchema,
serversSchema
],
schemaVersion: 9,
schemaVersion: 10,
migration: (oldRealm, newRealm) => {
if (oldRealm.schemaVersion >= 1 && newRealm.schemaVersion <= 9) {
const newServers = newRealm.objects('servers');
Expand Down
32 changes: 32 additions & 0 deletions app/lib/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import {
setUser, setLoginServices, loginRequest, loginFailure, logout
} from '../actions/login';
import { disconnect, connectSuccess, connectRequest } from '../actions/connect';
import {
shareSelectServer, shareSetUser
} from '../actions/share';

import subscribeRooms from './methods/subscriptions/rooms';
import subscribeRoom from './methods/subscriptions/room';
Expand Down Expand Up @@ -217,6 +220,35 @@ const RocketChat = {
});
},

async shareExtensionInit(server) {
database.setActiveDB(server);

if (this.sdk) {
this.sdk.disconnect();
this.sdk = null;
}

// Use useSsl: false only if server url starts with http://
const useSsl = !/http:\/\//.test(server);

this.sdk = new RocketchatClient({ host: server, protocol: 'ddp', useSsl });

// set Server
const { serversDB } = database.databases;
reduxStore.dispatch(shareSelectServer(server));

// set User info
const userId = await RNUserDefaults.get(`${ RocketChat.TOKEN_KEY }-${ server }`);
const user = userId && serversDB.objectForPrimaryKey('user', userId);
reduxStore.dispatch(shareSetUser({
id: user.id,
token: user.token,
username: user.username
}));

await RocketChat.login({ resume: user.token });
},

register(credentials) {
// RC 0.50.0
return this.sdk.post('users.register', credentials, false);
Expand Down
2 changes: 1 addition & 1 deletion app/presentation/DirectoryItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DirectoryItem = ({
<RoomTypeIcon type={type} />
<Text style={styles.directoryItemName} numberOfLines={1}>{title}</Text>
</View>
<Text style={styles.directoryItemUsername} numberOfLines={1}>{description}</Text>
{ description ? <Text style={styles.directoryItemUsername} numberOfLines={1}>{description}</Text> : null }
</View>
<DirectoryItemLabel text={rightLabel} />
</View>
Expand Down
4 changes: 2 additions & 2 deletions app/presentation/ServerItem/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export default StyleSheet.create({
alignItems: 'center'
},
serverIcon: {
width: 38,
height: 38,
width: 44,
height: 44,
marginHorizontal: 15,
borderRadius: 4
},
Expand Down
4 changes: 3 additions & 1 deletion app/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import app from './app';
import sortPreferences from './sortPreferences';
import notification from './notification';
import markdown from './markdown';
import share from './share';

export default combineReducers({
settings,
Expand All @@ -24,5 +25,6 @@ export default combineReducers({
rooms,
sortPreferences,
notification,
markdown
markdown,
share
});
Loading