2018-03-02 15:11:34 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-03-15 20:16:34 +00:00
|
|
|
import { FlatList } from 'react-native';
|
2018-09-19 14:18:32 +00:00
|
|
|
import { connect } from 'react-redux';
|
2019-09-16 20:26:32 +00:00
|
|
|
import { Q } from '@nozbe/watermelondb';
|
2021-03-15 20:16:34 +00:00
|
|
|
import * as List from '../../containers/List';
|
2018-03-02 15:11:34 +00:00
|
|
|
|
|
|
|
import styles from './styles';
|
2018-08-31 16:46:33 +00:00
|
|
|
import UserItem from '../../presentation/UserItem';
|
2018-03-02 15:11:34 +00:00
|
|
|
import scrollPersistTaps from '../../utils/scrollPersistTaps';
|
|
|
|
import RocketChat from '../../lib/rocketchat';
|
2019-09-16 20:26:32 +00:00
|
|
|
import database from '../../lib/database';
|
2019-07-23 14:02:57 +00:00
|
|
|
import { LISTENER } from '../../containers/Toast';
|
|
|
|
import EventEmitter from '../../utils/events';
|
2018-05-18 17:55:08 +00:00
|
|
|
import log from '../../utils/log';
|
2018-06-01 17:38:13 +00:00
|
|
|
import I18n from '../../i18n';
|
2018-08-31 18:13:30 +00:00
|
|
|
import SearchBox from '../../containers/SearchBox';
|
2019-02-26 12:46:27 +00:00
|
|
|
import protectedFunction from '../../lib/methods/helpers/protectedFunction';
|
2020-10-30 16:15:58 +00:00
|
|
|
import * as HeaderButton from '../../containers/HeaderButton';
|
2019-03-12 16:23:06 +00:00
|
|
|
import StatusBar from '../../containers/StatusBar';
|
2019-12-04 16:39:53 +00:00
|
|
|
import ActivityIndicator from '../../containers/ActivityIndicator';
|
|
|
|
import { withTheme } from '../../theme';
|
|
|
|
import { themes } from '../../constants/colors';
|
2020-02-11 14:09:14 +00:00
|
|
|
import { getUserSelector } from '../../selectors/login';
|
2020-06-15 19:35:45 +00:00
|
|
|
import { withActionSheet } from '../../containers/ActionSheet';
|
|
|
|
import { showConfirmationAlert } from '../../utils/info';
|
2020-06-15 14:00:46 +00:00
|
|
|
import SafeAreaView from '../../containers/SafeAreaView';
|
|
|
|
import { goRoom } from '../../utils/goRoom';
|
2018-03-02 15:11:34 +00:00
|
|
|
|
2019-04-17 17:01:03 +00:00
|
|
|
const PAGE_SIZE = 25;
|
|
|
|
|
2021-03-15 20:16:34 +00:00
|
|
|
const PERMISSION_MUTE_USER = 'mute-user';
|
|
|
|
const PERMISSION_SET_LEADER = 'set-leader';
|
|
|
|
const PERMISSION_SET_OWNER = 'set-owner';
|
|
|
|
const PERMISSION_SET_MODERATOR = 'set-moderator';
|
|
|
|
const PERMISSION_REMOVE_USER = 'remove-user';
|
|
|
|
|
2019-08-07 13:51:34 +00:00
|
|
|
class RoomMembersView extends React.Component {
|
2018-03-02 15:11:34 +00:00
|
|
|
static propTypes = {
|
2019-03-12 16:23:06 +00:00
|
|
|
navigation: PropTypes.object,
|
2020-06-15 14:00:46 +00:00
|
|
|
route: PropTypes.object,
|
2018-07-10 13:40:32 +00:00
|
|
|
rid: PropTypes.string,
|
2018-09-19 14:18:32 +00:00
|
|
|
members: PropTypes.array,
|
2018-12-21 10:55:35 +00:00
|
|
|
baseUrl: PropTypes.string,
|
2019-02-07 19:58:20 +00:00
|
|
|
room: PropTypes.object,
|
|
|
|
user: PropTypes.shape({
|
|
|
|
id: PropTypes.string,
|
|
|
|
token: PropTypes.string
|
2019-12-04 16:39:53 +00:00
|
|
|
}),
|
2020-06-15 19:35:45 +00:00
|
|
|
showActionSheet: PropTypes.func,
|
2020-06-15 14:00:46 +00:00
|
|
|
theme: PropTypes.string,
|
2020-11-30 20:00:31 +00:00
|
|
|
isMasterDetail: PropTypes.bool,
|
2021-03-15 20:16:34 +00:00
|
|
|
useRealName: PropTypes.bool,
|
|
|
|
muteUserPermission: PropTypes.array,
|
|
|
|
setLeaderPermission: PropTypes.array,
|
|
|
|
setOwnerPermission: PropTypes.array,
|
|
|
|
setModeratorPermission: PropTypes.array,
|
|
|
|
removeUserPermission: PropTypes.array
|
2018-03-02 15:11:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
2019-05-28 13:03:08 +00:00
|
|
|
super(props);
|
2019-09-16 20:26:32 +00:00
|
|
|
this.mounted = false;
|
2020-06-15 19:35:45 +00:00
|
|
|
this.MUTE_INDEX = 0;
|
2020-06-15 14:00:46 +00:00
|
|
|
const rid = props.route.params?.rid;
|
|
|
|
const room = props.route.params?.room;
|
2018-03-02 15:11:34 +00:00
|
|
|
this.state = {
|
2019-04-17 17:01:03 +00:00
|
|
|
isLoading: false,
|
2018-03-02 15:11:34 +00:00
|
|
|
allUsers: false,
|
|
|
|
filtering: false,
|
|
|
|
rid,
|
2019-04-17 17:01:03 +00:00
|
|
|
members: [],
|
2018-04-24 19:34:03 +00:00
|
|
|
membersFiltered: [],
|
2019-09-16 20:26:32 +00:00
|
|
|
room: room || {},
|
2019-04-17 17:01:03 +00:00
|
|
|
end: false
|
2018-03-02 15:11:34 +00:00
|
|
|
};
|
2019-09-17 14:43:49 +00:00
|
|
|
if (room && room.observe) {
|
|
|
|
this.roomObservable = room.observe();
|
|
|
|
this.subscription = this.roomObservable
|
|
|
|
.subscribe((changes) => {
|
|
|
|
if (this.mounted) {
|
|
|
|
this.setState({ room: changes });
|
|
|
|
} else {
|
|
|
|
this.state.room = changes;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-06-15 14:00:46 +00:00
|
|
|
this.setHeader();
|
2018-03-02 15:11:34 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
async componentDidMount() {
|
|
|
|
this.mounted = true;
|
2018-12-05 20:52:08 +00:00
|
|
|
this.fetchMembers();
|
2019-03-12 16:23:06 +00:00
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
const { room } = this.state;
|
2021-03-15 20:16:34 +00:00
|
|
|
const {
|
|
|
|
muteUserPermission, setLeaderPermission, setOwnerPermission, setModeratorPermission, removeUserPermission
|
|
|
|
} = this.props;
|
|
|
|
const result = await RocketChat.hasPermission([
|
|
|
|
muteUserPermission, setLeaderPermission, setOwnerPermission, setModeratorPermission, removeUserPermission
|
|
|
|
], room.rid);
|
|
|
|
|
|
|
|
this.permissions = {
|
|
|
|
[PERMISSION_MUTE_USER]: result[0],
|
|
|
|
[PERMISSION_SET_LEADER]: result[1],
|
|
|
|
[PERMISSION_SET_OWNER]: result[2],
|
|
|
|
[PERMISSION_SET_MODERATOR]: result[3],
|
|
|
|
[PERMISSION_REMOVE_USER]: result[4]
|
|
|
|
};
|
2020-11-30 20:00:31 +00:00
|
|
|
|
|
|
|
const hasSinglePermission = Object.values(this.permissions).some(p => !!p);
|
|
|
|
if (hasSinglePermission) {
|
|
|
|
this.fetchRoomMembersRoles();
|
|
|
|
}
|
2018-12-21 10:55:35 +00:00
|
|
|
}
|
|
|
|
|
2018-04-24 19:34:03 +00:00
|
|
|
componentWillUnmount() {
|
2019-09-16 20:26:32 +00:00
|
|
|
if (this.subscription && this.subscription.unsubscribe) {
|
|
|
|
this.subscription.unsubscribe();
|
|
|
|
}
|
2018-04-24 19:34:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 14:00:46 +00:00
|
|
|
setHeader = () => {
|
|
|
|
const { allUsers } = this.state;
|
|
|
|
const { navigation } = this.props;
|
|
|
|
const toggleText = allUsers ? I18n.t('Online') : I18n.t('All');
|
|
|
|
navigation.setOptions({
|
|
|
|
title: I18n.t('Members'),
|
|
|
|
headerRight: () => (
|
2020-10-30 16:15:58 +00:00
|
|
|
<HeaderButton.Container>
|
|
|
|
<HeaderButton.Item title={toggleText} onPress={this.toggleStatus} testID='room-members-view-toggle-status' />
|
|
|
|
</HeaderButton.Container>
|
2020-06-15 14:00:46 +00:00
|
|
|
)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-02-26 12:46:27 +00:00
|
|
|
onSearchChangeText = protectedFunction((text) => {
|
|
|
|
const { members } = this.state;
|
|
|
|
let membersFiltered = [];
|
|
|
|
|
|
|
|
if (members && members.length > 0 && text) {
|
Merge 4.16.0 into single-server (#3057)
* [FIX] RoomItem using deprecated animated event signature (#2771)
* [FIX] Server autocomplete text breaking line (#2774)
* [FIX] ServerDropdown flashing bigger server icon (#2775)
* [FIX] ServerDropdown flashing bigger server icon
* Remove unused logo and update image path where needed
* Minor tweak
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Rooms list not being updated on some cases (#2765)
* Request subscriptions on RoomsListView.constructor
* Removes opened rooms from last message persisting
* Change server reducer
* Prevent undefined ids causing query error
* [FIX] Share Extension hitting memory limit on iOS (#2788)
* [FIX] Disallow swipe to dismiss on share extension
* Limit query to 20 and clean up props
* Remove rn-extension-share branch pointer
* Test new branch
* Remove branch
* [IMPROVEMENT] Threads layout tweaks (#2686)
* improvement: Thread Details
* fix: re-render Thread Messages Item
* fix: update snapshots
* improve: thread details component
* fix: cast replies length
* improvement: format date of threads
* improvement: thread details styles
* fix: wrap text
* tests: update snapshot
* improvement: use same date format for all dates
* Icon size 24
* Remove date
* Remove prop drill
* Badge position
* Badge container tweak
* Fix inline style
* Move ThreadDetails to containers
* Update stories
* Fix lint
* Remove wrong prop
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Remove some migrations (#2792)
* Remove force rooms refresh
* Remove MMKV migration
* Bump version to 4.14.0 (#2797)
* [FIX] Messagebox tracking lost on pop gesture navigation (#2799)
* Use setTimeout instead of InteractionManager
* Update tracking lib
* [FIX] Back button closing activity when on root stack screen (#2804)
* Make hardware back button to behave as home button on root screens
* Remove unnecessary code
* Remove handleBackPress from OnboardingView
* Fix lint
* [i18n] Add missing German strings (#2715)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [NEW] Encrypted Discussions (#2813)
* I18n key fix
* Add encrypted switch
* Remove unused i18n keys
* Add enabled to encryption reducer
* Show encrypted option on CreateDiscussionView only when e2e encryption is properly set
* Add localSearch and use it on search
* Use encrypted from parent channel
* Fix method calls as rest api with 2fa enabled
* Fix logout after reset keys
* Use encryption reducer instead of lib directly to check render
* Check for room type logic to display encryption option on create discussion
* Check toggle-room-e2e-encryption permission on RoomActionsView
* Check for encryption status instead of setting on server
* Fix
* Disable switch instead of hide it
* Fix spotlight for DMs
* Fix server test
* [FIX] Messagebox missing style for text color (#2786)
* Changing auxilaryTintColor
* Changed Placeholder color to BodyText color
* added color prop
* eslint changes
* used array for styles
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [I18N] Update arabic (#2696)
* Update ar.js
* Update ar.js
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Workspace input without i18n (#2689)
* [FIX] Translation of strings in Login page
* Strings are added for translation.
fixes: #2620
* Add pt-BR
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Spotlight returning duplicated entries (#2805)
* Update rocketchat.js
* Updated search function
* Minor improvements
* Remove atIndex
* Add remove logic to remove duplicate data from response
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Refactor ServerItem (#2778)
* Updated ServerDropdown and ServerItem
* Added ServerItem stories
* Update ServerDropdown.js
* Updated ServerItem stories
* Updated ServerItem stories and ServerItem component
* Updated SelectServerView, ServerItem and ServerItem stories
* Updated ServerItem stories
* Updated ServerItem stories
* Update tests
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [DOCS] Updated Quick Start docs link in e2e/readme (#2802)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [I18N] Add Turkish (#2793)
* Turkish language support added
* Update tr.js
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Lint on #2793 (#2818)
* [I18N] Add missing german strings (#2689) (#2820)
* [I18N] Add missing italian strings (#2817)
* [FIX] Server version becoming null on server change (#2821)
* [FIX] Wrong styling on E2E encryption banner (#2767)
* [FIX] Wrong styling on E2E encryption banner
* [FIX] Wrong styling on E2E encryption banner
* [FIX] Wrong styling on E2E encryption banner
* [FIX] Wrong styling on E2E encryption banner (#2767)
* Updated SortDropdown, ListHeader, ListItem and added stories for List.Item
* Updated SortDropdown
* Removed unused component
* Updated List.Item and stories
* Reverted unnecessary changes and updated ListItem stories
* Fix minor indentation
* Stop breaking Touch's default underlay color
* Fix indentation
* Remove falsy comparison from render
* Fix left icon
* Use List.Item on OmnichannelStatus
* Add missing separator
* Lint
* Fix sort dropdown
* Remove unnecessary styles
* Fix detox
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] App Store using Experimental's app id (#2826)
* [FIX] Wrong username on push notifications (#2825)
* [FIX] Share extension memory issues on iOS (#2845)
* Remove unnecessary class prop
* Stop rendering servers when there's only one
* Map and alloc only necessary columns from query
* Fetch servers count instead of all servers records
* Fetch only needed servers
* Separators
* Remove renderContent
* Minor fix
* Refactor query
* Smaller avatars in memory
* Fix getItemLayout
* Add topic
* Load less pods
* tests
* Import only used functions from lodash
* Fix pods
* Import only used functions from semver
* Fix media sharing
* Update pods
* Disables preview and thumb on iOS
* Update expo-video-thumbnail
* Unnecessary change
* [FIX] Logout from other locations not prompting confirmation option (#2854)
* Fixed logout toast bug for the iOS
* Removing callToAction and replacing with confirmationText
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* Bump version to 4.14.1 (#2859)
* [IMPROVEMENT] Check for focused rooms on in-app notifications (#2857)
* Update InAppNotification and room reducer
* Update InAppNotification
This reverts commit 60330a1e04cfe8d2e5aa311f367083d831682c49.
* Stop subscribing to threads
* Remove ref
* Fix prop-types
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Real name being ignored in SearchMessagesView (#2838)
Co-authored-by: Gerzon Z <gerzonc@icloud.com>
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Remove unnecessary share reducer calls (#2861)
* Remove unnecesary share reducer calls
* Update Avatar
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Breadcrumbs exceeding characters limit (#2862)
* [FIX] breadcrumbs exceeding
* fix.breadcrumbs-exceeding-change-events
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] App compressing videos on iOS (#2915)
* Update index.js
* Update index.js
* [FIX] Real name setting ignored on reply preview (#2908)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Reply component sending unused prop to Description (#2900)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] BackdropOpacity based on themes (#2863)
* Added backdropOpacity based on theme
* Updated ActionSheet, ReactionsModal, ReactionPicker and Sidebar
* Updated MultiSelect
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Webview not falling back to default auth challenge when no cert is provided (#2918)
* [FIX] Android - fallback to default auth challenge handling when no cert is provided
* If a certificate auth challenge is requested on Android the webview will hang if no certificate is loaded.
To prevent this, fallback to default Android behavior and cancel the challenge with request.cancel()
* No client certificate case defaults to super implementation
* Update react-native-webview
* Downgrade to previous dependency version
Co-authored-by: Diego Mello <diegolmello@gmail.com>
Co-authored-by: Gerzon Z <gerzonc@icloud.com>
Co-authored-by: Jan Garaj <jan.garaj@gmail.com>
* [FIX] Support Jitsi_URL_Room_Hash (#2905)
* [FIX] Temp attachment files not being flushed after saved to gallery (#2871)
* Update AttachmentView.js
* Update AttachmentView.js
* Update AttachmentView.js
* Update AttachmentView.js
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Update iOS profiles for Experimental app (#2933)
* [IMPROVE] Deleted thread reply redirects to thread (#2840)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Thread showing typing indicator from main room (#2869)
* [FIX] Remove typing indicator from thread's header
* remove unnecessary props and change usersTyping condition
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] DM rooms show typing status from last group room (#2878)
* [FIX] DM rooms show typing status from last group room
* Undo changes
* Check if current typing is from focused room before dispatching to redux
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Can't copy or edit media's description (#2885)
* [FIX] Image descriptions issues
* shorten the condition string
* fix selectedMessage state
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] RightButtonsContainer re-render check not returning default value (#2899)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Remove InteractionManager blocks (#2906)
* [FIX] Remove InteractionManager blocks
* Minor fix
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] App not sending second argument for EventEmitter.removeListener on some places (#2909)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Temp message ignoring real name (#2919)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] System message of e2e encryption is missing (#2888)
* [FIX] System message of e2e encryption missing
* add new encryption string
* add to stories
* Add pt-BR
* Move stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Add permissions to Redux (#2914)
* [FIX] Add permissions to Redux store
* add only permissions being used in the app
* add clear permissions reducer
* call RocketChat.hasPermission from reducer
* add server version comparison on getPermissions
* refactor hasPermission function
* refactor hasPermission function
* remove uncomment code
* use Q.experimentalSortBy()
* add coerce function
* Change Rocketchat.hasPermission
* Apply on isReadOnly
* Apply to RoomInfoEditView
* Apply to RoomInfoView and RoomInfoEditView
* canAutoTranslate
* Unnecessary clear permissions
* Revert getUpdatedSince
* Naming fix
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Add hold step for ios and android build experimental (#2943)
* [CHORE] Add hold step for ios-build-experimental and android-build-experimental
* Android hold step
* add ios hold step
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [IMPROVEMENT] Remove lodash.isEqual (#2893)
* Added dequal and react-fast-compare as substitutes to lodash.isEqual
* Update ReplyPreview.js
* Remove react-fast-compare
* Removed deep-equal and upgrade babel-eslint dev dependency
* Fix avatar
* Fix Messagebox
* Fix CreateDiscussionView
* ModalBlockView
* NewMessageView
* ProfileView
* RoomInfoEditView
* ServerDropdown
* Return local search as object instead of observable
* SelectedUsersView
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [I18N] Add missing Russian strings (#2946)
* [i18n] Add missing Russian strings
* Couple fixes
* Fix Direct_message
Translate Direct_message as already has been translated
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Use shortcut syntax for get collections (#2932)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Use List.Separator in all places (#2931)
* [FIX] Use List.Separator in all places
* add List.Separator
* change List.Separator
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Limit new message list query size to 50 (#2947)
* Limit query to 50
* Remove observable
* [FIX] Support chats order for older versions of the server (#2934)
* Update mergeSubscriptionsRooms.js
* Update mergeSubscriptionsRooms.js
* Update mergeSubscriptionsRooms.js
* Minor refactor
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Reactions modal's backdrop color too light (#2949)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* Bump version to 4.15.0 (#2950)
* [FIX] Share extension not working correctly on Official app (#2963)
* [FIX] Cannot read property 'some' of undefined on hasPermission (#2966)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Deep linking and other connectivity issues (#2894)
* Navigate from push notification only if necessary
* Use JS SDK branch
* Stop reconnecting if it's already connected
* Fix RoomsListView forever loading after tapping push notification of another server
* Execute fewer operations on app/index
* Remove roomsRequest call from onForeground
* Apply check and reopen
* Stop opening in-app notification when the app is on backgorund
* Connecting tweaks
* Fix deep linking not working if the app is on background
* Force reset yarn cache
* Upgrade JS SDK
* Remove listener on unmount
* Fix resume on Android after back button is pressed
* Fix local authentication resume
* Fix back button android
* Change JS SDK branch
* [FIX] Messagebox's placeholder color is too bright (#2968)
* [IMPROVEMENT] Message attachment colors (#2860)
* Added convertStrToHex function and updated Reply component
* Removed convertStrtToHex function and added attachmentBackground
* Added color2k, removed transparent view and applied transparentize to backgroundColor
* Added stories
* Update Reply stories
* Update Reply stories
* Fix lint
* Update Reply stories
* Fix props
* Move tests to Message stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] App forgetting workspace when server is not finished added (#2798)
* [FIX] App forgetting workspace
* Added e2e tests
* Update login.js
* Update logout.js
* Reverted changes on login and share, updated init
* Update 08-persistantworkspace.spec.js
* Revert unnecessary changes
* Revert line change
* Update share.js
* Tweak tests
* Use wm shorthand
* Remove irrelevant calls to RocketChat.TOKEN_KEY
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [TESTS] Add E2E tests to draft message (#2960)
* [E2E TEST] Draft message
* Fix tests
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [TESTS] Add E2E tests to group DM (#2961)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [TESTS] Add E2E tests to directory (#2964)
* [E2E TEST] Directory
* Fix tests
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Simplify server version comparison (#2922)
* Simplify server version where needed
* Added lte and gte functions and updated imports
* Updated functions names
* Update util functions
* Update util function and added methods
* Remove lt and coerce from getPermissions and mergeSubscriptionsRooms
* Fix comparison
* Update getPermissions.js
* Remove unused import
* Fix lint
* Fix lint
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [TESTS] Add E2E tests to discussions (#2970)
* [E2E TEST] Discussions
* fix error Cannot find UI elemen
* Fix tests
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Attachment not rendering markdown (#2924)
* [FIX] Render markdown in Fields content
* Added stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [TESTS] Add e2e tests for mark message as unread (#2953)
* [E2E TEST] Add e2e tests for mark message as unread
* fixed test for draft message
* change test name
* move test to other file
* Remove unnecessary tests
* Rename file
* Update jest tests
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [TESTS] Add E2E tests to delete server (#2954)
* [E2E TEST] Delete server
* fixed test for delete server
* fix tests
* minor changes
* Rename file
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Refactor RoomActionsView permissions (#2872)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [CHORE] Add status and teams icons (#2989)
Co-authored-by: Gerzon Z <gerzonc@icloud.com>
* [FIX] SSO not working with 2FA (TOTP) (#2978)
* Update AuthenticationWebView.js
* Updated loginTOTP
* Added validation
* Update rocketchat.js
* Update rocketchat.js
* Update rocketchat.js
* Update rocketchat.js
* Fix resolve
* Remove incognito
* Fix totp being requested on webview
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [IMPROVEMENT] User status icons (#2991)
* Add status and teams
* Update icons, icon size and getUsersPresence
* Minor changes
* Refactor RoomTypeIcon
* Minor tweaks
* Update unit tests
* Minor fixes
* Fix styles
* Small refactor
* Update jest
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [REGRESSION] Auth via deep linking not working (#3015)
* Update rocketchat and add e2e test for deep linking
* Update rocketchat and add e2e test for deep linking
* Update deeplinking e2e
* fix deep linking auth
* Test deep linking auth
* Fix deeplink to rid and add tests
* Small refactor
* Add non existing server test
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Create discussion request being sent with null value on encryption param (#3033)
* [CHORE] Use JSON files for i18n (#3011)
* [IMPROVEMENT] Load only i18n files needed (#3014)
* Use json
* Load only i18n files needed
* [REGRESSION] Clear local server cache not loading rooms (#3007)
* Fix clear cache
* Write e2e tests
* Fix lint
* Fix isRTL
* [FIX] Custom OAuth and iframe login attempts being called multiple times (#3020)
* [FIX] App crashing when attachment color is an invalid HEX (#3021)
* [IMPROVEMENT] Add "Message" option to Room Info (#3029)
* [CHORE] Go to room from hashtag
* Layout tweaks
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Can't change status (#3018)
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Search input not using the whole header space (#3012)
* [FIX] Search input not using the whole space
* Fix on getHeaderTitlePosition
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] E2EE password hiding automatically (#2972)
* [FIX] E2EE password hiding automatically
* add e2e test
* fixed hiding banner
* move e2e tests to 01-e2eencryption
* remove console.log
* Fix tests
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [TESTS] Move threads tests to its own file (#2965)
* [E2E TEST] Move threads test to another file
* changed descirbe title
* Rearrange files
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Regex typo on markdown (#2928)
* [FIX] Fix Regex Typo
* Add story for testing
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Make attachment validation compatible with web client (#2927)
* [FIX] Make attachment validation compatible with web client
* Added stories
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Non-reply attachments displaying time (#2902)
* Remove time if no message_link
* Fix message stories for replies
* Final stories fix
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] i18n not being applied on login/register labels (#2930)
* Use I18n translate in login text input label
* Add to register and add missing strings
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* Revert "[FIX] Make attachment validation compatible with web client (#2927)" (#3036)
This reverts commit d6200745c028dd47b4ce0f11eb396c8f2a4cf807.
* Bump version to 4.16.0 (#3037)
* [NEW] Basic support to Teams (#3016)
* Database migration
* RoomItem icon
* Team icons
* Teams group
* Small tweak on RoomTypeIcon
* RoomView Header
* Add team's channels to RoomView header
* Starting TeamChannelsView
* Icon size
* o data found
* Update TeamChannelsView, add teams subscriptions and send params to TeamChannelsView
* Use teams.ListRooms endpoint, render rooms list, remove unused functions
* Show team main on TeamChannelsView
* Disable swipe
* Pagination working
* Fix blinking no data found
* Search working
* Refactor to use BackgroundContainer while loading
* Go to room
* Cleanup
* Go to actions
* Events
* Lint
* Add debounce to go room
* Fix for tablet
* i18n
* Small fix
* Minor refactor
* Use local data when it exists
* Show last message
* Force teams migration
* Add stories to BackgroundContainer
* Remove unused component
* Move RoomViewHeader into containers folder
* Refactoring
* Testing RoomHeader
* i18n
* Fix server endpoint version
* Fix events
Co-authored-by: Gerzon Z <gerzonzcanario@gmail.com>
* [CHORE] Refactor mention tracking logic (#2997)
* [Improvement] Improve mentions
This PR focuses on improving command, emoji, channel and user mentions.
* [Tests] Added e2e tests for mention improvement
* [Improvement] Modify slash command mention logic.
Added slash command with argument preview
Slash command should show only if the message bigins with /
* Return data on search for empty text
* Minor fixes
* Update e2e tests
* Minor fix
* [FIX] allow command mentioning in between text
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Status text not being updated on sidebar (#3041)
* Update StatusView.js
* Minor tweak
* Minor tweaks
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* [FIX] Unable to search non-latin alphabet names on members list (#3039)
* Add search by name in members list
* Update RoomMembersView search
Co-authored-by: Diego Mello <diegolmello@gmail.com>
* Search stops working after some time (#3044)
Co-authored-by: Gerzon Z <gerzonzcanario@gmail.com>
Co-authored-by: Gerzon Z <gerzonc@icloud.com>
Co-authored-by: Djorkaeff Alexandre <djorkaeff.unb@gmail.com>
Co-authored-by: phriedrich <info@phriedrich.de>
Co-authored-by: yash-rajpal <58601732+yash-rajpal@users.noreply.github.com>
Co-authored-by: Fazil Boudjelal <fazildiablou@hotmail.fr>
Co-authored-by: Sumukha Hegde <SUMUKHA214@GMAIL.COM>
Co-authored-by: Hakan YILMAZ <mukerrem.yilmaz@hotmail.com>
Co-authored-by: Vincenzo Esposito <aenon.esposito@gmail.com>
Co-authored-by: Arkadyuti Bandyopadhyay <bandyopadhyayarkadyuti@gmail.com>
Co-authored-by: Anant Bhasin <38764067+aKn1ghtOut@users.noreply.github.com>
Co-authored-by: Gung Wah <41157464+kresnaputra@users.noreply.github.com>
Co-authored-by: Billy Newman <newmanw10@gmail.com>
Co-authored-by: Jan Garaj <jan.garaj@gmail.com>
Co-authored-by: ankar84 <ankar84@gmail.com>
Co-authored-by: sadegh <sadeghmohamadnia@yahoo.com>
2021-04-13 13:39:06 +00:00
|
|
|
membersFiltered = members.filter(m => m.username.toLowerCase().match(text.toLowerCase()) || m.name.toLowerCase().match(text.toLowerCase()));
|
2019-02-26 12:46:27 +00:00
|
|
|
}
|
|
|
|
this.setState({ filtering: !!text, membersFiltered });
|
|
|
|
})
|
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
navToDirectMessage = async(item) => {
|
2018-05-18 17:55:08 +00:00
|
|
|
try {
|
2019-09-16 20:26:32 +00:00
|
|
|
const db = database.active;
|
2021-03-15 20:16:34 +00:00
|
|
|
const subsCollection = db.get('subscriptions');
|
2019-09-16 20:26:32 +00:00
|
|
|
const query = await subsCollection.query(Q.where('name', item.username)).fetch();
|
2020-01-07 17:31:37 +00:00
|
|
|
if (query.length) {
|
2019-09-16 20:26:32 +00:00
|
|
|
const [room] = query;
|
2020-06-15 14:00:46 +00:00
|
|
|
this.goRoom(room);
|
2018-05-18 17:55:08 +00:00
|
|
|
} else {
|
2018-12-05 20:52:08 +00:00
|
|
|
const result = await RocketChat.createDirectMessage(item.username);
|
|
|
|
if (result.success) {
|
2020-06-15 14:00:46 +00:00
|
|
|
this.goRoom({ rid: result.room?._id, name: item.username, t: 'd' });
|
2018-12-05 20:52:08 +00:00
|
|
|
}
|
2018-05-18 17:55:08 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
2019-08-23 13:18:47 +00:00
|
|
|
log(e);
|
2018-03-02 15:11:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
onPressUser = (selectedUser) => {
|
2019-01-30 12:11:02 +00:00
|
|
|
const { room } = this.state;
|
2020-11-30 20:00:31 +00:00
|
|
|
const { showActionSheet, user } = this.props;
|
2018-12-21 10:55:35 +00:00
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
const options = [{
|
|
|
|
icon: 'message',
|
|
|
|
title: I18n.t('Direct_message'),
|
|
|
|
onPress: () => this.navToDirectMessage(selectedUser)
|
|
|
|
}];
|
2020-06-15 19:35:45 +00:00
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
// Owner
|
|
|
|
if (this.permissions['set-owner']) {
|
|
|
|
const userRoleResult = this.roomRoles.find(r => r.u._id === selectedUser._id);
|
|
|
|
const isOwner = userRoleResult?.roles.includes('owner');
|
|
|
|
options.push({
|
|
|
|
icon: 'shield-check',
|
|
|
|
title: I18n.t(isOwner ? 'Remove_as_owner' : 'Set_as_owner'),
|
|
|
|
onPress: () => this.handleOwner(selectedUser, !isOwner)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Leader
|
|
|
|
if (this.permissions['set-leader']) {
|
|
|
|
const userRoleResult = this.roomRoles.find(r => r.u._id === selectedUser._id);
|
|
|
|
const isLeader = userRoleResult?.roles.includes('leader');
|
|
|
|
options.push({
|
|
|
|
icon: 'shield-alt',
|
|
|
|
title: I18n.t(isLeader ? 'Remove_as_leader' : 'Set_as_leader'),
|
|
|
|
onPress: () => this.handleLeader(selectedUser, !isLeader)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Moderator
|
|
|
|
if (this.permissions['set-moderator']) {
|
|
|
|
const userRoleResult = this.roomRoles.find(r => r.u._id === selectedUser._id);
|
|
|
|
const isModerator = userRoleResult?.roles.includes('moderator');
|
|
|
|
options.push({
|
|
|
|
icon: 'shield',
|
|
|
|
title: I18n.t(isModerator ? 'Remove_as_moderator' : 'Set_as_moderator'),
|
|
|
|
onPress: () => this.handleModerator(selectedUser, !isModerator)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ignore
|
|
|
|
if (selectedUser._id !== user.id) {
|
|
|
|
const { ignored } = room;
|
|
|
|
const isIgnored = ignored?.includes?.(selectedUser._id);
|
|
|
|
options.push({
|
|
|
|
icon: 'ignore',
|
|
|
|
title: I18n.t(isIgnored ? 'Unignore' : 'Ignore'),
|
|
|
|
onPress: () => this.handleIgnore(selectedUser, !isIgnored)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.permissions['mute-user']) {
|
|
|
|
const { muted = [] } = room;
|
|
|
|
const userIsMuted = muted.find?.(m => m === selectedUser.username);
|
|
|
|
selectedUser.muted = !!userIsMuted;
|
|
|
|
options.push({
|
2020-07-29 21:02:51 +00:00
|
|
|
icon: userIsMuted ? 'audio' : 'audio-disabled',
|
2020-06-15 19:35:45 +00:00
|
|
|
title: I18n.t(userIsMuted ? 'Unmute' : 'Mute'),
|
|
|
|
onPress: () => {
|
|
|
|
showConfirmationAlert({
|
|
|
|
message: I18n.t(`The_user_${ userIsMuted ? 'will' : 'wont' }_be_able_to_type_in_roomName`, {
|
|
|
|
roomName: RocketChat.getRoomTitle(room)
|
|
|
|
}),
|
2020-08-25 20:04:18 +00:00
|
|
|
confirmationText: I18n.t(userIsMuted ? 'Unmute' : 'Mute'),
|
2020-11-30 20:00:31 +00:00
|
|
|
onPress: () => this.handleMute(selectedUser)
|
2020-06-15 19:35:45 +00:00
|
|
|
});
|
|
|
|
}
|
2020-11-30 20:00:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove from room
|
|
|
|
if (this.permissions['remove-user']) {
|
|
|
|
options.push({
|
|
|
|
icon: 'logout',
|
|
|
|
title: I18n.t('Remove_from_room'),
|
|
|
|
danger: true,
|
|
|
|
onPress: () => {
|
|
|
|
showConfirmationAlert({
|
|
|
|
message: I18n.t('The_user_will_be_removed_from_s', { s: RocketChat.getRoomTitle(room) }),
|
|
|
|
confirmationText: I18n.t('Yes_remove_user'),
|
|
|
|
onPress: () => this.handleRemoveUserFromRoom(selectedUser)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
showActionSheet({
|
|
|
|
options,
|
2020-06-15 19:35:45 +00:00
|
|
|
hasCancel: true
|
|
|
|
});
|
2019-01-30 12:11:02 +00:00
|
|
|
}
|
|
|
|
|
2019-03-12 16:23:06 +00:00
|
|
|
toggleStatus = () => {
|
|
|
|
try {
|
|
|
|
const { allUsers } = this.state;
|
2019-04-17 17:01:03 +00:00
|
|
|
this.setState({ members: [], allUsers: !allUsers, end: false }, () => {
|
|
|
|
this.fetchMembers();
|
|
|
|
});
|
2019-03-12 16:23:06 +00:00
|
|
|
} catch (e) {
|
2019-08-23 13:18:47 +00:00
|
|
|
log(e);
|
2019-03-12 16:23:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
fetchRoomMembersRoles = async() => {
|
|
|
|
try {
|
|
|
|
const { room } = this.state;
|
|
|
|
const result = await RocketChat.getRoomRoles(room.rid, room.t);
|
|
|
|
if (result?.success) {
|
|
|
|
this.roomRoles = result.roles;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-17 17:01:03 +00:00
|
|
|
fetchMembers = async() => {
|
|
|
|
const {
|
|
|
|
rid, members, isLoading, allUsers, end
|
|
|
|
} = this.state;
|
|
|
|
if (isLoading || end) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({ isLoading: true });
|
2019-04-08 12:35:28 +00:00
|
|
|
try {
|
2019-04-17 17:01:03 +00:00
|
|
|
const membersResult = await RocketChat.getRoomMembers(rid, allUsers, members.length, PAGE_SIZE);
|
|
|
|
const newMembers = membersResult.records;
|
|
|
|
this.setState({
|
|
|
|
members: members.concat(newMembers || []),
|
|
|
|
isLoading: false,
|
|
|
|
end: newMembers.length < PAGE_SIZE
|
|
|
|
});
|
2020-06-15 14:00:46 +00:00
|
|
|
this.setHeader();
|
2019-08-23 13:18:47 +00:00
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
2019-04-08 12:35:28 +00:00
|
|
|
this.setState({ isLoading: false });
|
|
|
|
}
|
2018-12-05 20:52:08 +00:00
|
|
|
}
|
|
|
|
|
2020-06-15 14:00:46 +00:00
|
|
|
goRoom = (item) => {
|
|
|
|
const { navigation, isMasterDetail } = this.props;
|
|
|
|
if (isMasterDetail) {
|
|
|
|
navigation.navigate('DrawerNavigator');
|
|
|
|
} else {
|
|
|
|
navigation.popToTop();
|
|
|
|
}
|
|
|
|
goRoom({ item, isMasterDetail });
|
2018-07-10 13:40:32 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
getUserDisplayName = (user) => {
|
|
|
|
const { useRealName } = this.props;
|
|
|
|
return (useRealName ? user.name : user.username) || user.username;
|
|
|
|
}
|
|
|
|
|
2020-06-15 19:35:45 +00:00
|
|
|
handleMute = async(user) => {
|
|
|
|
const { rid } = this.state;
|
2018-04-24 19:34:03 +00:00
|
|
|
try {
|
2020-06-15 19:35:45 +00:00
|
|
|
await RocketChat.toggleMuteUserInRoom(rid, user?.username, !user?.muted);
|
|
|
|
EventEmitter.emit(LISTENER, { message: I18n.t('User_has_been_key', { key: user?.muted ? I18n.t('unmuted') : I18n.t('muted') }) });
|
2018-05-18 17:55:08 +00:00
|
|
|
} catch (e) {
|
2019-08-23 13:18:47 +00:00
|
|
|
log(e);
|
2018-04-24 19:34:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-30 20:00:31 +00:00
|
|
|
handleOwner = async(selectedUser, isOwner) => {
|
|
|
|
try {
|
|
|
|
const { room } = this.state;
|
|
|
|
await RocketChat.toggleRoomOwner({
|
|
|
|
roomId: room.rid, t: room.t, userId: selectedUser._id, isOwner
|
|
|
|
});
|
|
|
|
const message = isOwner ? 'User__username__is_now_a_owner_of__room_name_' : 'User__username__removed_from__room_name__owners';
|
|
|
|
EventEmitter.emit(LISTENER, {
|
|
|
|
message: I18n.t(message, {
|
|
|
|
username: this.getUserDisplayName(selectedUser),
|
|
|
|
room_name: RocketChat.getRoomTitle(room)
|
|
|
|
})
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
this.fetchRoomMembersRoles();
|
|
|
|
}
|
|
|
|
|
|
|
|
handleLeader = async(selectedUser, isLeader) => {
|
|
|
|
try {
|
|
|
|
const { room } = this.state;
|
|
|
|
await RocketChat.toggleRoomLeader({
|
|
|
|
roomId: room.rid, t: room.t, userId: selectedUser._id, isLeader
|
|
|
|
});
|
|
|
|
const message = isLeader ? 'User__username__is_now_a_leader_of__room_name_' : 'User__username__removed_from__room_name__leaders';
|
|
|
|
EventEmitter.emit(LISTENER, {
|
|
|
|
message: I18n.t(message, {
|
|
|
|
username: this.getUserDisplayName(selectedUser),
|
|
|
|
room_name: RocketChat.getRoomTitle(room)
|
|
|
|
})
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
this.fetchRoomMembersRoles();
|
|
|
|
}
|
|
|
|
|
|
|
|
handleModerator = async(selectedUser, isModerator) => {
|
|
|
|
try {
|
|
|
|
const { room } = this.state;
|
|
|
|
await RocketChat.toggleRoomModerator({
|
|
|
|
roomId: room.rid, t: room.t, userId: selectedUser._id, isModerator
|
|
|
|
});
|
|
|
|
const message = isModerator ? 'User__username__is_now_a_moderator_of__room_name_' : 'User__username__removed_from__room_name__moderators';
|
|
|
|
EventEmitter.emit(LISTENER, {
|
|
|
|
message: I18n.t(message, {
|
|
|
|
username: this.getUserDisplayName(selectedUser),
|
|
|
|
room_name: RocketChat.getRoomTitle(room)
|
|
|
|
})
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
this.fetchRoomMembersRoles();
|
|
|
|
}
|
|
|
|
|
|
|
|
handleIgnore = async(selectedUser, ignore) => {
|
|
|
|
try {
|
|
|
|
const { room } = this.state;
|
|
|
|
await RocketChat.ignoreUser({
|
|
|
|
rid: room.rid, userId: selectedUser._id, ignore
|
|
|
|
});
|
|
|
|
const message = I18n.t(ignore ? 'User_has_been_ignored' : 'User_has_been_unignored');
|
|
|
|
EventEmitter.emit(LISTENER, { message });
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
handleRemoveUserFromRoom = async(selectedUser) => {
|
|
|
|
try {
|
|
|
|
const { room, members, membersFiltered } = this.state;
|
|
|
|
const userId = selectedUser._id;
|
|
|
|
await RocketChat.removeUserFromRoom({ roomId: room.rid, t: room.t, userId });
|
|
|
|
const message = I18n.t('User_has_been_removed_from_s', { s: RocketChat.getRoomTitle(room) });
|
|
|
|
EventEmitter.emit(LISTENER, { message });
|
|
|
|
this.setState({
|
|
|
|
members: members.filter(member => member._id !== userId),
|
|
|
|
membersFiltered: membersFiltered.filter(member => member._id !== userId)
|
|
|
|
});
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-02 15:11:34 +00:00
|
|
|
renderSearchBar = () => (
|
2018-08-31 18:13:30 +00:00
|
|
|
<SearchBox onChangeText={text => this.onSearchChangeText(text)} testID='room-members-view-search' />
|
2018-03-02 15:11:34 +00:00
|
|
|
)
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
renderItem = ({ item }) => {
|
2019-12-04 16:39:53 +00:00
|
|
|
const { baseUrl, user, theme } = this.props;
|
2018-09-25 19:28:42 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<UserItem
|
|
|
|
name={item.name}
|
|
|
|
username={item.username}
|
|
|
|
onPress={() => this.onPressUser(item)}
|
|
|
|
baseUrl={baseUrl}
|
|
|
|
testID={`room-members-view-item-${ item.username }`}
|
2019-02-07 19:58:20 +00:00
|
|
|
user={user}
|
2019-12-04 16:39:53 +00:00
|
|
|
theme={theme}
|
2018-09-25 19:28:42 +00:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2018-03-02 15:11:34 +00:00
|
|
|
|
|
|
|
render() {
|
2018-12-21 10:55:35 +00:00
|
|
|
const {
|
2019-03-18 19:13:59 +00:00
|
|
|
filtering, members, membersFiltered, isLoading
|
2018-12-21 10:55:35 +00:00
|
|
|
} = this.state;
|
2019-12-04 16:39:53 +00:00
|
|
|
const { theme } = this.props;
|
2018-03-02 15:11:34 +00:00
|
|
|
return (
|
2020-10-30 13:59:44 +00:00
|
|
|
<SafeAreaView testID='room-members-view'>
|
|
|
|
<StatusBar />
|
2018-04-24 19:34:03 +00:00
|
|
|
<FlatList
|
|
|
|
data={filtering ? membersFiltered : members}
|
|
|
|
renderItem={this.renderItem}
|
2019-12-04 16:39:53 +00:00
|
|
|
style={[styles.list, { backgroundColor: themes[theme].backgroundColor }]}
|
2018-04-24 19:34:03 +00:00
|
|
|
keyExtractor={item => item._id}
|
2021-03-15 20:16:34 +00:00
|
|
|
ItemSeparatorComponent={List.Separator}
|
2018-04-24 19:34:03 +00:00
|
|
|
ListHeaderComponent={this.renderSearchBar}
|
2019-04-17 17:01:03 +00:00
|
|
|
ListFooterComponent={() => {
|
|
|
|
if (isLoading) {
|
2019-12-04 16:39:53 +00:00
|
|
|
return <ActivityIndicator theme={theme} />;
|
2019-04-17 17:01:03 +00:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}}
|
|
|
|
onEndReachedThreshold={0.1}
|
|
|
|
onEndReached={this.fetchMembers}
|
|
|
|
maxToRenderPerBatch={5}
|
|
|
|
windowSize={10}
|
2018-04-24 19:34:03 +00:00
|
|
|
{...scrollPersistTaps}
|
2018-08-01 19:35:06 +00:00
|
|
|
/>
|
|
|
|
</SafeAreaView>
|
2018-03-02 15:11:34 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
2020-02-11 14:09:14 +00:00
|
|
|
baseUrl: state.server.server,
|
2020-06-15 14:00:46 +00:00
|
|
|
user: getUserSelector(state),
|
2020-11-30 20:00:31 +00:00
|
|
|
isMasterDetail: state.app.isMasterDetail,
|
2021-03-15 20:16:34 +00:00
|
|
|
useRealName: state.settings.UI_Use_Real_Name,
|
|
|
|
muteUserPermission: state.permissions[PERMISSION_MUTE_USER],
|
|
|
|
setLeaderPermission: state.permissions[PERMISSION_SET_LEADER],
|
|
|
|
setOwnerPermission: state.permissions[PERMISSION_SET_OWNER],
|
|
|
|
setModeratorPermission: state.permissions[PERMISSION_SET_MODERATOR],
|
|
|
|
removeUserPermission: state.permissions[PERMISSION_REMOVE_USER]
|
2019-08-07 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
2020-06-15 19:35:45 +00:00
|
|
|
export default connect(mapStateToProps)(withActionSheet(withTheme(RoomMembersView)));
|