From a92da8801bcb4bad3c0f4491fc6af282e16661ed Mon Sep 17 00:00:00 2001 From: Romaric Mourgues Date: Wed, 21 Sep 2022 11:50:26 +0200 Subject: [PATCH] Fix #2528 and #2527 --- .../src/app/components/user-card/user-card.tsx | 16 +++++++++------- .../applications/messages/messages-list.tsx | 17 +++++++++++++---- .../channels-bar/Parts/Channel/ChannelMenu.tsx | 7 +++++-- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/twake/frontend/src/app/components/user-card/user-card.tsx b/twake/frontend/src/app/components/user-card/user-card.tsx index c787cdeb5e..5850a8b892 100644 --- a/twake/frontend/src/app/components/user-card/user-card.tsx +++ b/twake/frontend/src/app/components/user-card/user-card.tsx @@ -39,13 +39,15 @@ export default (props: PropsType): JSX.Element => { {props.user.email} -
-
+ {UserService.isInCompany(props.user, companyId) && ( +
+
+ )} ); diff --git a/twake/frontend/src/app/views/applications/messages/messages-list.tsx b/twake/frontend/src/app/views/applications/messages/messages-list.tsx index 2a08a80e35..db23fccf32 100644 --- a/twake/frontend/src/app/views/applications/messages/messages-list.tsx +++ b/twake/frontend/src/app/views/applications/messages/messages-list.tsx @@ -23,6 +23,7 @@ import messageApiClient from 'app/features/messages/api/message-api-client'; import User from 'app/features/users/services/current-user-service'; import { useChannelMembersReadSections } from 'app/features/channel-members/hooks/use-channel-members-read-sections'; import { delayRequest } from 'app/features/global/utils/managedSearchRequest'; +import { useRefreshPublicOrPrivateChannels } from 'app/features/channels/hooks/use-public-or-private-channels'; type Props = { companyId: string; @@ -80,6 +81,8 @@ export default ({ channelId, companyId, workspaceId, readonly }: Props) => { ); }; + const { refresh: refreshChannels } = useRefreshPublicOrPrivateChannels(); + useEffect(() => { if (messages.length === 0) loadMore('history'); }, []); @@ -147,8 +150,13 @@ export default ({ channelId, companyId, workspaceId, readonly }: Props) => { }, [highlight, messages.length]); useEffect(() => { - if (messages.length) - ChannelAPIClient.read(companyId, workspaceId || '', channelId || '', { status: true }); + if (messages.length) { + ChannelAPIClient.read(companyId, workspaceId || '', channelId || '', { status: true }).then( + () => { + refreshChannels(); + }, + ); + } }, [messages.length > 0]); useEffect(() => { @@ -239,12 +247,13 @@ export default ({ channelId, companyId, workspaceId, readonly }: Props) => { itemContent={row} followOutput={!!window.reachedEnd && 'smooth'} loadMore={loadMoreMessages} - atBottomStateChange={(atBottom: boolean) => { + atBottomStateChange={async (atBottom: boolean) => { if (atBottom && window.reachedEnd) { setAtBottom(true); - ChannelAPIClient.read(companyId, workspaceId || '', channelId || '', { + await ChannelAPIClient.read(companyId, workspaceId || '', channelId || '', { status: true, }); + refreshChannels(); } }} /> diff --git a/twake/frontend/src/app/views/client/channels-bar/Parts/Channel/ChannelMenu.tsx b/twake/frontend/src/app/views/client/channels-bar/Parts/Channel/ChannelMenu.tsx index b5c33367a0..6662cd6f47 100644 --- a/twake/frontend/src/app/views/client/channels-bar/Parts/Channel/ChannelMenu.tsx +++ b/twake/frontend/src/app/views/client/channels-bar/Parts/Channel/ChannelMenu.tsx @@ -24,6 +24,7 @@ import AccessRightsService from 'app/features/workspace-members/services/workspa import ChannelWorkspaceEditor from 'app/views/client/channels-bar/Modals/ChannelWorkspaceEditor'; import { addUrlTryDesktop } from 'app/views/desktop-redirect'; import Menu from 'components/menus/menu'; +import { useRefreshPublicOrPrivateChannels } from 'app/features/channels/hooks/use-public-or-private-channels'; type PropsType = { channel: ChannelType; @@ -53,10 +54,10 @@ const FullMenu = (props: PropsType): JSX.Element => { const { badges } = useChannelNotifications(props.channel.id || ''); const { user: currentUser } = useCurrentUser(); const { refresh: refreshFavoriteChannels } = useRefreshFavoriteChannels(); - const { refresh: refreshDirectChannels } = useRefreshDirectChannels(); const { refresh: refreshChannel } = useChannel(props.channel.id || ''); const channelMember = props.channel.user_member || {}; const { setOpen: setParticipantsOpen } = useUsersSearchModal(); + const { refresh: refreshChannels } = useRefreshPublicOrPrivateChannels(); Languages.useListener(); @@ -113,7 +114,7 @@ const FullMenu = (props: PropsType): JSX.Element => { } else { redirectToWorkspace(); refreshFavoriteChannels(); - refreshDirectChannels(); + refreshChannels(); } refreshChannel(); @@ -148,6 +149,7 @@ const FullMenu = (props: PropsType): JSX.Element => { await ChannelsMineAPIClient.removeChannel(companyId, workspaceId, props.channel.id).then( redirectToWorkspace, ); + refreshChannels(); } }; @@ -166,6 +168,7 @@ const FullMenu = (props: PropsType): JSX.Element => { props.channel.id || '', { status: badges.length > 0, now: true }, ); + refreshChannels(); }, }, {