[FIX] Show ActivityIndicator in RoomMembersView (#686)

This commit is contained in:
pranavpandey1998official 2019-03-19 00:43:59 +05:30 committed by Diego Mello
parent e8f1a694c6
commit 2814a6e091
2 changed files with 15 additions and 4 deletions

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { FlatList, View } from 'react-native'; import { FlatList, View, ActivityIndicator } from 'react-native';
import ActionSheet from 'react-native-action-sheet'; import ActionSheet from 'react-native-action-sheet';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { SafeAreaView } from 'react-navigation'; import { SafeAreaView } from 'react-navigation';
@ -67,6 +67,7 @@ export default class RoomMembersView extends LoggedView {
this.rooms = database.objects('subscriptions').filtered('rid = $0', rid); this.rooms = database.objects('subscriptions').filtered('rid = $0', rid);
this.permissions = RocketChat.hasPermission(['mute-user'], rid); this.permissions = RocketChat.hasPermission(['mute-user'], rid);
this.state = { this.state = {
isLoading: true,
allUsers: false, allUsers: false,
filtering: false, filtering: false,
rid, rid,
@ -88,7 +89,7 @@ export default class RoomMembersView extends LoggedView {
shouldComponentUpdate(nextProps, nextState) { shouldComponentUpdate(nextProps, nextState) {
const { const {
allUsers, filtering, members, membersFiltered, userLongPressed, room, options allUsers, filtering, members, membersFiltered, userLongPressed, room, options, isLoading
} = this.state; } = this.state;
if (nextState.allUsers !== allUsers) { if (nextState.allUsers !== allUsers) {
return true; return true;
@ -111,6 +112,9 @@ export default class RoomMembersView extends LoggedView {
if (!equal(nextState.room.muted, room.muted)) { if (!equal(nextState.room.muted, room.muted)) {
return true; return true;
} }
if (isLoading !== nextState.isLoading) {
return true;
}
return false; return false;
} }
@ -184,11 +188,12 @@ export default class RoomMembersView extends LoggedView {
} }
fetchMembers = async(status) => { fetchMembers = async(status) => {
this.setState({ isLoading: true });
const { rid } = this.state; const { rid } = this.state;
const { navigation } = this.props; const { navigation } = this.props;
const membersResult = await RocketChat.getRoomMembers(rid, status); const membersResult = await RocketChat.getRoomMembers(rid, status);
const members = membersResult.records; const members = membersResult.records;
this.setState({ allUsers: status, members }); this.setState({ allUsers: status, members, isLoading: false });
navigation.setParams({ allUsers: status }); navigation.setParams({ allUsers: status });
} }
@ -249,8 +254,11 @@ export default class RoomMembersView extends LoggedView {
render() { render() {
const { const {
filtering, members, membersFiltered filtering, members, membersFiltered, isLoading
} = this.state; } = this.state;
if (isLoading) {
return <ActivityIndicator style={styles.loading} />;
}
return ( return (
<SafeAreaView style={styles.list} testID='room-members-view' forceInset={{ bottom: 'never' }}> <SafeAreaView style={styles.list} testID='room-members-view' forceInset={{ bottom: 'never' }}>
<StatusBar /> <StatusBar />

View File

@ -46,5 +46,8 @@ export default StyleSheet.create({
headerButton: { headerButton: {
marginRight: 9, marginRight: 9,
alignItems: 'flex-end' alignItems: 'flex-end'
},
loading: {
flex: 1
} }
}); });