* 🐞Bug Fix: Channel_leave_and_join_redirection
* Update chat.jsx
This commit is contained in:
parent
1375bf676e
commit
048cf874f5
5 changed files with 27 additions and 12 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
>
|
||||
{' '}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ const Display = ({ resource }) => {
|
|||
<ChatChannelSettings
|
||||
resource={resource.data}
|
||||
activeMembershipId={resource.activeMembershipId}
|
||||
handleLeavingChannel={resource.handleLeavingChannel}
|
||||
/>
|
||||
);
|
||||
default:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue