Rocket.Chat.ReactNative/app/views/ShareListView/index.js

434 lines
11 KiB
JavaScript
Raw Normal View History

2019-07-18 17:44:02 +00:00
import React from 'react';
import PropTypes from 'prop-types';
import {
View, Text, FlatList, ActivityIndicator, Keyboard, BackHandler
2019-07-18 17:44:02 +00:00
} from 'react-native';
import { SafeAreaView } from 'react-navigation';
2019-07-18 17:44:02 +00:00
import ShareExtension from 'rn-extensions-share';
import { connect } from 'react-redux';
import RNFetchBlob from 'rn-fetch-blob';
import * as mime from 'react-native-mime-types';
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
import { isEqual, orderBy } from 'lodash';
import { Q } from '@nozbe/watermelondb';
2019-07-18 17:44:02 +00:00
2019-07-29 16:33:28 +00:00
import Navigation from '../../lib/ShareNavigation';
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
import database from '../../lib/database';
2019-07-18 17:44:02 +00:00
import { isIOS, isAndroid } from '../../utils/deviceInfo';
import I18n from '../../i18n';
import { CustomIcon } from '../../lib/Icons';
import log from '../../utils/log';
import { canUploadFile } from '../../utils/media';
2019-07-18 17:44:02 +00:00
import DirectoryItem, { ROW_HEIGHT } from '../../presentation/DirectoryItem';
2019-07-29 16:33:28 +00:00
import ServerItem from '../../presentation/ServerItem';
2019-07-18 17:44:02 +00:00
import { CloseShareExtensionButton, CustomHeaderButtons, Item } from '../../containers/HeaderButton';
import ShareListHeader from './Header';
import styles from './styles';
2019-07-29 16:33:28 +00:00
import StatusBar from '../../containers/StatusBar';
import { animateNextTransition } from '../../utils/layoutAnimation';
2019-07-18 17:44:02 +00:00
2019-07-29 16:33:28 +00:00
const LIMIT = 50;
const getItemLayout = (data, index) => ({ length: ROW_HEIGHT, offset: ROW_HEIGHT * index, index });
2019-07-18 17:44:02 +00:00
const keyExtractor = item => item.rid;
class ShareListView extends React.Component {
2019-07-18 17:44:02 +00:00
static navigationOptions = ({ navigation }) => {
const searching = navigation.getParam('searching');
2019-07-29 16:33:28 +00:00
const initSearch = navigation.getParam('initSearch', () => {});
const cancelSearch = navigation.getParam('cancelSearch', () => {});
const search = navigation.getParam('search', () => {});
if (isIOS) {
return {
headerTitle: (
<ShareListHeader
searching={searching}
initSearch={initSearch}
cancelSearch={cancelSearch}
search={search}
/>
)
};
}
2019-07-18 17:44:02 +00:00
return {
2019-07-29 16:33:28 +00:00
headerBackTitle: null,
2019-07-18 17:44:02 +00:00
headerLeft: searching
? (
<CustomHeaderButtons left>
2019-07-29 16:33:28 +00:00
<Item title='cancel' iconName='cross' onPress={cancelSearch} />
2019-07-18 17:44:02 +00:00
</CustomHeaderButtons>
)
: (
<CloseShareExtensionButton
onPress={ShareExtension.close}
testID='share-extension-close'
/>
),
2019-07-29 16:33:28 +00:00
headerTitle: <ShareListHeader searching={searching} search={search} />,
2019-07-18 17:44:02 +00:00
headerRight: (
searching
? null
: (
<CustomHeaderButtons>
2019-07-29 16:33:28 +00:00
{isAndroid ? <Item title='search' iconName='magnifier' onPress={initSearch} /> : null}
2019-07-18 17:44:02 +00:00
</CustomHeaderButtons>
)
)
};
}
static propTypes = {
navigation: PropTypes.object,
server: PropTypes.string,
baseUrl: PropTypes.string,
token: PropTypes.string,
2019-07-29 16:33:28 +00:00
userId: PropTypes.string
2019-07-18 17:44:02 +00:00
}
constructor(props) {
super(props);
this.data = [];
this.state = {
2019-07-29 16:33:28 +00:00
showError: false,
2019-07-18 17:44:02 +00:00
searching: false,
2019-07-29 16:33:28 +00:00
searchText: '',
2019-07-18 17:44:02 +00:00
value: '',
isMedia: false,
mediaLoading: false,
fileInfo: null,
2019-07-29 16:33:28 +00:00
searchResults: [],
2019-07-18 17:44:02 +00:00
chats: [],
2019-07-29 16:33:28 +00:00
servers: [],
loading: true,
serverInfo: null
2019-07-18 17:44:02 +00:00
};
2019-07-29 16:33:28 +00:00
this.didFocusListener = props.navigation.addListener('didFocus', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress));
this.willBlurListener = props.navigation.addListener('willBlur', () => BackHandler.addEventListener('hardwareBackPress', this.handleBackPress));
2019-07-18 17:44:02 +00:00
}
async componentDidMount() {
2019-07-29 16:33:28 +00:00
const { navigation, server } = this.props;
2019-07-18 17:44:02 +00:00
navigation.setParams({
2019-07-29 16:33:28 +00:00
initSearch: this.initSearch,
cancelSearch: this.cancelSearch,
search: this.search
2019-07-18 17:44:02 +00:00
});
try {
const { value, type } = await ShareExtension.data();
let fileInfo = null;
const isMedia = (type === 'media');
if (isMedia) {
this.setState({ mediaLoading: true });
const data = await RNFetchBlob.fs.stat(this.uriToPath(value));
fileInfo = {
name: data.filename,
description: '',
size: data.size,
mime: mime.lookup(data.path),
2019-07-18 17:44:02 +00:00
path: isIOS ? data.path : `file://${ data.path }`
};
}
this.setState({
value, fileInfo, isMedia, mediaLoading: false
});
} catch (e) {
log(e);
2019-07-18 17:44:02 +00:00
this.setState({ mediaLoading: false });
}
2019-07-29 16:33:28 +00:00
this.getSubscriptions(server);
2019-07-18 17:44:02 +00:00
}
componentWillReceiveProps(nextProps) {
2019-07-29 16:33:28 +00:00
const { server } = this.props;
if (nextProps.server !== server) {
this.getSubscriptions(nextProps.server);
2019-07-18 17:44:02 +00:00
}
}
shouldComponentUpdate(nextProps, nextState) {
2019-07-29 16:33:28 +00:00
const { searching } = this.state;
if (nextState.searching !== searching) {
2019-07-18 17:44:02 +00:00
return true;
}
2019-07-29 16:33:28 +00:00
const { isMedia } = this.state;
if (nextState.isMedia !== isMedia) {
this.getSubscriptions(nextProps.server, nextState.fileInfo);
return true;
}
const { server } = this.props;
if (server !== nextProps.server) {
2019-07-18 17:44:02 +00:00
return true;
}
2019-07-29 16:33:28 +00:00
const { searchResults } = this.state;
if (!isEqual(nextState.searchResults, searchResults)) {
2019-07-18 17:44:02 +00:00
return true;
}
return false;
}
// eslint-disable-next-line react/sort-comp
internalSetState = (...args) => {
const { navigation } = this.props;
if (navigation.isFocused()) {
animateNextTransition();
2019-07-18 17:44:02 +00:00
}
this.setState(...args);
}
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
getSubscriptions = async(server, fileInfo) => {
const { fileInfo: fileData } = this.state;
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
const db = database.active;
const serversDB = database.servers;
2019-07-18 17:44:02 +00:00
if (server) {
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
this.data = await db.collections
.get('subscriptions')
.query(
Q.where('archived', false),
Q.where('open', true)
).fetch();
this.data = orderBy(this.data, ['roomUpdatedAt'], ['desc']);
const serversCollection = serversDB.collections.get('servers');
this.servers = await serversCollection.query().fetch();
2019-07-29 16:33:28 +00:00
this.chats = this.data.slice(0, LIMIT);
2019-10-08 12:36:15 +00:00
let serverInfo = {};
try {
serverInfo = await serversCollection.find(server);
} catch (error) {
// Do nothing
}
2019-09-24 20:16:59 +00:00
const canUploadFileResult = canUploadFile(fileInfo || fileData, serverInfo);
2019-07-18 17:44:02 +00:00
this.internalSetState({
chats: this.chats ? this.chats.slice() : [],
servers: this.servers ? this.servers.slice() : [],
2019-07-29 16:33:28 +00:00
loading: false,
2019-09-24 20:16:59 +00:00
showError: !canUploadFileResult.success,
error: canUploadFileResult.error,
2019-07-29 16:33:28 +00:00
serverInfo
2019-07-18 17:44:02 +00:00
});
this.forceUpdate();
2019-07-29 16:33:28 +00:00
}
};
uriToPath = uri => decodeURIComponent(isIOS ? uri.replace(/^file:\/\//, '') : uri);
2019-07-18 17:44:02 +00:00
getRoomTitle = (item) => {
2019-07-29 16:33:28 +00:00
const { serverInfo } = this.state;
const { useRealName } = serverInfo;
2019-07-18 17:44:02 +00:00
return ((item.prid || useRealName) && item.fname) || item.name;
}
shareMessage = (item) => {
const { value, isMedia, fileInfo } = this.state;
const { navigation } = this.props;
navigation.navigate('ShareView', {
rid: item.rid,
value,
isMedia,
fileInfo,
name: this.getRoomTitle(item)
});
}
search = (text) => {
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
const result = this.data.filter(item => item.name.includes(text)) || [];
2019-07-18 17:44:02 +00:00
this.internalSetState({
2019-07-29 16:33:28 +00:00
searchResults: result.slice(0, LIMIT),
searchText: text
2019-07-18 17:44:02 +00:00
});
}
2019-07-29 16:33:28 +00:00
initSearch = () => {
const { chats } = this.state;
const { navigation } = this.props;
this.setState({ searching: true, searchResults: chats });
2019-07-18 17:44:02 +00:00
navigation.setParams({ searching: true });
}
2019-07-29 16:33:28 +00:00
cancelSearch = () => {
const { navigation } = this.props;
this.internalSetState({ searching: false, searchResults: [], searchText: '' });
navigation.setParams({ searching: false });
Keyboard.dismiss();
}
handleBackPress = () => {
const { searching } = this.state;
if (searching) {
this.cancelSearch();
return true;
2019-07-18 17:44:02 +00:00
}
2019-07-29 16:33:28 +00:00
return false;
2019-07-18 17:44:02 +00:00
}
2019-07-29 16:33:28 +00:00
renderSectionHeader = (header) => {
const { searching } = this.state;
if (searching) {
return null;
}
2019-07-18 17:44:02 +00:00
2019-07-29 16:33:28 +00:00
return (
<View style={styles.headerContainer}>
<Text style={styles.headerText}>
{I18n.t(header)}
</Text>
</View>
);
}
2019-07-18 17:44:02 +00:00
renderItem = ({ item }) => {
const { userId, token, baseUrl } = this.props;
return (
<DirectoryItem
user={{
userId,
token
}}
title={this.getRoomTitle(item)}
baseUrl={baseUrl}
avatar={this.getRoomTitle(item)}
description={
item.t === 'c'
? (item.topic || item.description)
: item.fname
}
type={item.t}
onPress={() => this.shareMessage(item)}
testID={`share-extension-item-${ item.name }`}
/>
);
}
renderSeparator = () => <View style={styles.separator} />;
2019-07-29 16:33:28 +00:00
renderBorderBottom = () => <View style={styles.borderBottom} />;
2019-07-18 17:44:02 +00:00
2019-07-29 16:33:28 +00:00
renderSelectServer = () => {
2019-07-18 17:44:02 +00:00
const { servers } = this.state;
const { server } = this.props;
const currentServer = servers.find(serverFiltered => serverFiltered.id === server);
return currentServer ? (
<>
2019-07-18 17:44:02 +00:00
{this.renderSectionHeader('Select_Server')}
<View style={styles.bordered}>
<ServerItem
server={server}
[CHORE] Migrate to Watermelon (#1171) * Install * Create subscriptions * Subscription observing and sorting * Saving last message * Stash * Stash * stash * Stash * Rooms list listing :) * Animated set state * Search working * Fix load rooms on login * stash db class * set active db with path * Remove db on logout * stash * Created updateMessages * Inserting/updating threads * Persisting thread messages * Removed unused list * Loading messages from watermelon * Debounce updates and rerender message * optional fields * Fix realm conflict issues * Fix some render issues * stash * List mount * stash * fix message id * Fix tmsg * - Save subscription.rid as id on watermelon and _id as _id - Send room as param to room view * Throttle room updates * stash * comment removeClippedSubviews * Fetch thread name * try/catch updateMessages * Show loading while RoomView.init is still running * stash * Fix updateMessages * Threads * Delete message * Permalink * Pin * Star * Report * MessageActions refactor * Edit message * Reply message * Add reaction * Auto translate * Fix connection issues * Mark message as error if something happened on the call * Error actions * get custom emoji * Always run console.log when __DEV__ * Try to create serversDB * Don't call updateMessages. Execute that entire logic for one message id instead. * Refactor update messages * ServersDB User [Realm -> Watermelon] * Fix models * Custom emojis * Custom emojis on emoji picker * Frequently used emojis * Fix add reaction on message * stash * Fix * Read messages * Fix thread * Fetch thread header * Follow/unfollow thread * Fix thread * Upload file * Thread tweak * Realm -> Watermelon [Share Extension] * Add RoomsUpdatedAt to Servers Table * Settings * Settings * Fix logout * SendFileMessage ServersDB * ServersDB on serverDropdown * Remove serversDB from Realm * Load thread messages * Delete message * Improve getSettings * Improve * Remove subscription * Remove update * Update room via socket * Small refactor * Fix logout and improve migration * Refactor updateMessages * Improve migration * Remove unnecessary update * Revert remove runAfterInteractions * Fix serverDropdown * Fix merge * Init room actions Watermelon * Room actions Watermelon * Remove realm on room members * Room swipe -> Watermelon * Fix hideChannel * Get roles watermelon * Get permissions watermelon * Users typing + memory db * Auto translate watermelon * New Message View * Selected Users View * try/catch * Get Slash Commands watermelon * Slash Commands message box * Custom emojis message box * Get rooms message box * Room info view * Room info edit * Save active users * Small refactor * Message Actions * hasPermission await * last hasPermission fix * Active users on redux * Add user roles * Users typing on redux and remove memory db * Fix saga delay * Fix few issues * Fix slash commands preview * Draft message * Add muted * Unread count watermelon * Remove realm * Fiz RoomItem rerenders * Remove realm config * Rerender status update on RoomItem * Refactor RoomsListView * Fix load missed messages * Fix room update * Message refactor * Fixing lint * removeClippedSubviews on iOS only * Added few interaction managers * Fix few rerenders * Fix RoomItem status typo * Fix RoomView.SCU * Fix broadcast * Fix user status on RoomActionsView * Fix RocketChat.hasPermission * Fix database inconsistencies * Fix few update issues * Add rxjs and remove with observables * Fix tests * Remove subscriptions * Fix RoomsListView SCU * Change database structure and set all schemas to 1 * Fix RoomsListView search * Fixed errors, removed rerenders and added animation * Fixed a few errors * Fix lint * Fix issues caught by LGTM * fix ios build * Fix load unjoined channel messages * Log on database path on startup * Fix join channel * Remove react-native-realm-path * Set user status on login.user reducer * Fix status not rendering on RoomsListView * Fix few reducers * Fix users going offline * Never use "watermelon" term directly. Replaced by "database" * Fix custom emoji * Creating room from app must update roomUpdatedAt * Log subscribeRoom start * Fix room subscribe right after creating a DM * Refactor is read only on messages actions * Fix typo * Fix typo * Review * Fix schema * Fix muted & freq emoji & unpin & unstar * Remove throttleTime to room info & fix reset on edit room * Fix openServerDropdown spec & Fix unarchive * Fix MessageAction * Refactor RoomInfoEditView * Remove unnecessary condition * Remove unnecessary condition * Remove unnecessary condition * Remove get database * Rename Command.js to SlashCommand.js * Create sanitizer util * Fix indentation * Create subscription.t index * Refactor queries on RoomsListView * Create subscription.name index * Fix getPermissions * Fix indentation * Add missing await * Fix rocketchat.hasPermission * Unnecessary change * Star, pin e delete message refactored * Refactor customEmojis reducer * Remove code * Remove logs * Remove throttle * Call this.init on foreground focus on RoomView * Bump servers schema migration * Always mark message as sent after a success * Fetch only messages needed on updateMessages * Just leave a comment for now * Fetch only subscriptions returned by fetch * Set room param on RoomView header in find room * Update kotlin * Fix auto translate constructor * Fix few setState on constructor * Fix empty room image blinking while mounting * Improve fetch/persist execution for custom emojis, permissions and settings * Query only user tapped on RoomMembersView * Fix typo on canOpenRoom
2019-09-16 20:26:32 +00:00
onPress={() => Navigation.navigate('SelectServerView', { servers: this.servers })}
2019-07-18 17:44:02 +00:00
item={currentServer}
/>
</View>
</>
2019-07-18 17:44:02 +00:00
) : null;
}
2019-07-29 16:33:28 +00:00
renderEmptyComponent = () => (
<View style={[styles.container, styles.emptyContainer]}>
<Text style={styles.title}>{I18n.t('No_results_found')}</Text>
</View>
);
2019-07-18 17:44:02 +00:00
2019-07-29 16:33:28 +00:00
renderHeader = () => {
const { searching } = this.state;
2019-07-18 17:44:02 +00:00
return (
<>
2019-07-29 16:33:28 +00:00
{ !searching
? (
<>
2019-07-29 16:33:28 +00:00
{this.renderSelectServer()}
{this.renderSectionHeader('Chats')}
</>
2019-07-29 16:33:28 +00:00
)
: null
}
</>
2019-07-18 17:44:02 +00:00
);
}
2019-07-29 16:33:28 +00:00
renderContent = () => {
const {
chats, mediaLoading, loading, searchResults, searching, searchText
} = this.state;
2019-07-18 17:44:02 +00:00
if (mediaLoading || loading) {
return <ActivityIndicator style={styles.loading} />;
}
return (
2019-07-29 16:33:28 +00:00
<FlatList
data={searching ? searchResults : chats}
keyExtractor={keyExtractor}
style={styles.flatlist}
renderItem={this.renderItem}
getItemLayout={getItemLayout}
ItemSeparatorComponent={this.renderSeparator}
ListHeaderComponent={this.renderHeader}
ListFooterComponent={!searching && this.renderBorderBottom}
ListHeaderComponentStyle={!searching ? styles.borderBottom : {}}
ListEmptyComponent={searching && searchText ? this.renderEmptyComponent : null}
enableEmptySections
removeClippedSubviews
2019-07-18 17:44:02 +00:00
keyboardShouldPersistTaps='always'
2019-07-29 16:33:28 +00:00
initialNumToRender={12}
windowSize={20}
/>
2019-07-18 17:44:02 +00:00
);
}
renderError = () => {
2019-07-29 16:33:28 +00:00
const {
2019-09-24 20:16:59 +00:00
fileInfo: file, loading, searching, error
2019-07-29 16:33:28 +00:00
} = this.state;
if (loading) {
return <ActivityIndicator style={styles.loading} />;
}
2019-07-18 17:44:02 +00:00
return (
<View style={styles.container}>
2019-07-29 16:33:28 +00:00
{ !searching
? (
<>
2019-07-29 16:33:28 +00:00
{this.renderSelectServer()}
</>
2019-07-29 16:33:28 +00:00
)
: null
}
<View style={[styles.container, styles.centered]}>
2019-09-24 20:16:59 +00:00
<Text style={styles.title}>{I18n.t(error)}</Text>
2019-07-29 16:33:28 +00:00
<CustomIcon name='circle-cross' size={120} style={styles.errorIcon} />
<Text style={styles.fileMime}>{ file.mime }</Text>
2019-07-29 16:33:28 +00:00
</View>
2019-07-18 17:44:02 +00:00
</View>
);
}
render() {
2019-07-29 16:33:28 +00:00
const { showError } = this.state;
2019-07-18 17:44:02 +00:00
return (
<SafeAreaView style={styles.container} forceInset={{ vertical: 'never' }}>
2019-07-29 16:33:28 +00:00
<StatusBar />
{ showError ? this.renderError() : this.renderContent() }
2019-07-18 17:44:02 +00:00
</SafeAreaView>
);
}
}
const mapStateToProps = (({ share }) => ({
userId: share.user && share.user.id,
token: share.user && share.user.token,
server: share.server,
baseUrl: share ? share.server : ''
}));
export default connect(mapStateToProps)(ShareListView);