Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RomaricMourgues committed Sep 21, 2022
1 parent 47abbb2 commit a92da88
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
16 changes: 9 additions & 7 deletions twake/frontend/src/app/components/user-card/user-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ export default (props: PropsType): JSX.Element => {
<Emojione type=":envelope_with_arrow:" />
<a href={`mailto:${props.user.email}`}>{props.user.email}</a>
</div>
<div className="footer">
<Button
type="button"
value={Languages.t('general.send', [], 'Save')}
onClick={props.onClick}
/>
</div>
{UserService.isInCompany(props.user, companyId) && (
<div className="footer">
<Button
type="button"
value={Languages.t('general.send', [], 'Save')}
onClick={props.onClick}
/>
</div>
)}
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,6 +81,8 @@ export default ({ channelId, companyId, workspaceId, readonly }: Props) => {
);
};

const { refresh: refreshChannels } = useRefreshPublicOrPrivateChannels();

useEffect(() => {
if (messages.length === 0) loadMore('history');
}, []);
Expand Down Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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();
}
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -113,7 +114,7 @@ const FullMenu = (props: PropsType): JSX.Element => {
} else {
redirectToWorkspace();
refreshFavoriteChannels();
refreshDirectChannels();
refreshChannels();
}

refreshChannel();
Expand Down Expand Up @@ -148,6 +149,7 @@ const FullMenu = (props: PropsType): JSX.Element => {
await ChannelsMineAPIClient.removeChannel(companyId, workspaceId, props.channel.id).then(
redirectToWorkspace,
);
refreshChannels();
}
};

Expand All @@ -166,6 +168,7 @@ const FullMenu = (props: PropsType): JSX.Element => {
props.channel.id || '',
{ status: badges.length > 0, now: true },
);
refreshChannels();
},
},
{
Expand Down

0 comments on commit a92da88

Please sign in to comment.