[deploy] 🐞Bug Fix: Room that has been left still shows up in URL [Fixes: #9501] (#9804)

* 🐞Bug Fix: Channel_leave_and_join_redirection

* Update chat.jsx
This commit is contained in:
Sarthak Sharma 2020-08-18 18:59:40 +05:30 committed by GitHub
parent 1375bf676e
commit 048cf874f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 12 deletions

View file

@ -10,7 +10,8 @@ module ChatChannelMembershipsHelper
status: membership.status,
image: ProfileImage.new(membership.user).get(width: 90),
chat_channel_name: membership.chat_channel.channel_name,
chat_channel_id: membership.chat_channel.id
chat_channel_id: membership.chat_channel.id,
slug: membership.chat_channel.slug
}
end
end

View file

@ -18,6 +18,7 @@ import ChatChannelSettingsSection from './ChatChannelSettingsSection';
export default class ChatChannelSettings extends Component {
static propTypes = {
handleLeavingChannel: PropTypes.func.isRequired,
activeMembershipId: PropTypes.number.isRequired,
};
@ -308,7 +309,7 @@ export default class ChatChannelSettings extends Component {
if (actionStatus) {
const response = await leaveChatChannelMembership(currentMembership.id);
if (response.success) {
this.updateChannelDetails();
this.props.handleLeavingChannel(currentMembership.id);
} else {
this.setState({
successMessages: null,

View file

@ -17,7 +17,7 @@ const RequestListItem = ({ request, updateMembership }) => (
onClick={updateMembership}
data-channel-id={request.chat_channel_id}
data-membership-id={request.membership_id}
data-channel-slug={request.channel_modified_slug}
data-channel-slug={request.slug}
data-user-action="reject"
>
{' '}
@ -29,7 +29,7 @@ const RequestListItem = ({ request, updateMembership }) => (
onClick={updateMembership}
data-channel-id={request.chat_channel_id}
data-membership-id={request.membership_id}
data-channel-slug={request.channel_modified_slug}
data-channel-slug={request.slug}
data-user-action="accept"
>
{' '}

View file

@ -339,12 +339,7 @@ export default class Chat extends Component {
};
setupChannel = (channelId) => {
const {
messages,
messageOffset,
activeChannel,
activeChannelId,
} = this.state;
const { messages, messageOffset, activeChannel } = this.state;
if (
!messages[channelId] ||
messages[channelId].length === 0 ||
@ -354,7 +349,7 @@ export default class Chat extends Component {
}
if (activeChannel && activeChannel.channel_type !== 'direct') {
getContent(
`/chat_channels/${activeChannelId}/channel_info`,
`/chat_channels/${channelId}/channel_info`,
this.setOpenChannelUsers,
null,
);
@ -372,7 +367,7 @@ export default class Chat extends Component {
res.channel_users,
([username]) => username !== window.currentUser.username,
);
if (activeChannel.channel_type === 'open') {
if (activeChannel && activeChannel.channel_type === 'open') {
this.setState({
channelUsers: {
[activeChannelId]: leftUser,
@ -919,6 +914,7 @@ export default class Chat extends Component {
this.triggerSwitchChannel(
parseInt(acceptedInfo.channelId, 10),
acceptedInfo.channelSlug,
this.state.chatChannels,
);
}
@ -1022,6 +1018,7 @@ export default class Chat extends Component {
data: {},
type_of: 'chat-channel-setting',
activeMembershipId: activeChannel.id,
handleLeavingChannel: this.handleLeavingChannel,
});
}
}
@ -1062,6 +1059,21 @@ export default class Chat extends Component {
});
};
handleLeavingChannel = (leftChannelId) => {
const { chatChannels } = this.state;
this.triggerSwitchChannel(
chatChannels[1].chat_channel_id,
chatChannels[1].channel_modified_slug,
chatChannels,
);
this.setState((prevState) => ({
chatChannels: prevState.chatChannels.filter(
(channel) => channel.id !== leftChannelId,
),
}));
this.setActiveContentState(chatChannels[1].chat_channel_id, null);
};
triggerChannelTypeFilter = (e) => {
const { filterQuery } = this.state;
const type = e.target.dataset.channelType;

View file

@ -109,6 +109,7 @@ const Display = ({ resource }) => {
<ChatChannelSettings
resource={resource.data}
activeMembershipId={resource.activeMembershipId}
handleLeavingChannel={resource.handleLeavingChannel}
/>
);
default: