[FIX] Add loading prop on RoomActionsView to avoid double click (#4462)
This commit is contained in:
parent
8d26230e4f
commit
e3a99a93e4
|
@ -95,6 +95,7 @@ interface IRoomActionsViewState {
|
||||||
canCreateTeam: boolean;
|
canCreateTeam: boolean;
|
||||||
canAddChannelToTeam: boolean;
|
canAddChannelToTeam: boolean;
|
||||||
canConvertTeam: boolean;
|
canConvertTeam: boolean;
|
||||||
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomActionsViewState> {
|
class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomActionsViewState> {
|
||||||
|
@ -144,7 +145,8 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
canToggleEncryption: false,
|
canToggleEncryption: false,
|
||||||
canCreateTeam: false,
|
canCreateTeam: false,
|
||||||
canAddChannelToTeam: false,
|
canAddChannelToTeam: false,
|
||||||
canConvertTeam: false
|
canConvertTeam: false,
|
||||||
|
loading: false
|
||||||
};
|
};
|
||||||
if (room && room.observe && room.rid) {
|
if (room && room.observe && room.rid) {
|
||||||
this.roomObservable = room.observe();
|
this.roomObservable = room.observe();
|
||||||
|
@ -512,6 +514,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
if (!room.teamId) {
|
if (!room.teamId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.setState({ loading: true });
|
||||||
const result = await Services.teamListRoomsOfUser({ teamId: room.teamId, userId });
|
const result = await Services.teamListRoomsOfUser({ teamId: room.teamId, userId });
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
@ -531,6 +534,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
this.convertTeamToChannelConfirmation();
|
this.convertTeamToChannelConfirmation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.setState({ loading: false });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.convertTeamToChannelConfirmation();
|
this.convertTeamToChannelConfirmation();
|
||||||
}
|
}
|
||||||
|
@ -573,6 +577,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
if (!room.teamId) {
|
if (!room.teamId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.setState({ loading: true });
|
||||||
const result = await Services.teamListRoomsOfUser({ teamId: room.teamId, userId });
|
const result = await Services.teamListRoomsOfUser({ teamId: room.teamId, userId });
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
|
@ -598,6 +603,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.setState({ loading: false });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showConfirmationAlert({
|
showConfirmationAlert({
|
||||||
message: I18n.t('You_are_leaving_the_team', { team: getRoomTitle(room) }),
|
message: I18n.t('You_are_leaving_the_team', { team: getRoomTitle(room) }),
|
||||||
|
@ -889,7 +895,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
};
|
};
|
||||||
|
|
||||||
renderLastSection = () => {
|
renderLastSection = () => {
|
||||||
const { room, joined } = this.state;
|
const { room, joined, loading } = this.state;
|
||||||
const { theme } = this.props;
|
const { theme } = this.props;
|
||||||
const { t, blocker } = room;
|
const { t, blocker } = room;
|
||||||
|
|
||||||
|
@ -923,6 +929,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
<List.Section>
|
<List.Section>
|
||||||
<List.Separator />
|
<List.Separator />
|
||||||
<List.Item
|
<List.Item
|
||||||
|
disabled={loading}
|
||||||
title='Leave'
|
title='Leave'
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
this.onPressTouchable({
|
this.onPressTouchable({
|
||||||
|
@ -987,7 +994,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
};
|
};
|
||||||
|
|
||||||
teamToChannelActions = (t: string, room: ISubscription) => {
|
teamToChannelActions = (t: string, room: ISubscription) => {
|
||||||
const { canEdit, canConvertTeam } = this.state;
|
const { canEdit, canConvertTeam, loading } = this.state;
|
||||||
const canConvertTeamToChannel = canEdit && canConvertTeam && !!room?.teamMain;
|
const canConvertTeamToChannel = canEdit && canConvertTeam && !!room?.teamMain;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -996,6 +1003,7 @@ class RoomActionsView extends React.Component<IRoomActionsViewProps, IRoomAction
|
||||||
<>
|
<>
|
||||||
<List.Item
|
<List.Item
|
||||||
title='Convert_to_Channel'
|
title='Convert_to_Channel'
|
||||||
|
disabled={loading}
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
this.onPressTouchable({
|
this.onPressTouchable({
|
||||||
event: this.convertTeamToChannel
|
event: this.convertTeamToChannel
|
||||||
|
|
Loading…
Reference in New Issue