Skip to content

Commit

Permalink
Merge branch 'develop' into favorite-setting-functioning
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Feb 5, 2024
2 parents 256451e + ef68359 commit 8fa6543
Show file tree
Hide file tree
Showing 99 changed files with 2,264 additions and 467 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-years-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed an issue with the composer losing its edit state and highlighted after resizing the window.
6 changes: 6 additions & 0 deletions .changeset/flat-windows-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/web-ui-registration": patch
---

Fixed login email verification flow when a user tries to join with username
5 changes: 5 additions & 0 deletions .changeset/kind-dragons-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

feat: add a11y doc links
2 changes: 0 additions & 2 deletions apps/meteor/app/models/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { RoomRoles } from './models/RoomRoles';
import { UserAndRoom } from './models/UserAndRoom';
import { UserRoles } from './models/UserRoles';
import { Users } from './models/Users';
import { WebdavAccounts } from './models/WebdavAccounts';

export {
Base,
Expand All @@ -30,7 +29,6 @@ export {
ChatPermissions,
CustomSounds,
EmojiCustom,
WebdavAccounts,
/** @deprecated */
Users,
/** @deprecated */
Expand Down
9 changes: 0 additions & 9 deletions apps/meteor/app/models/client/models/WebdavAccounts.ts

This file was deleted.

47 changes: 0 additions & 47 deletions apps/meteor/app/webdav/client/actionButton.ts

This file was deleted.

15 changes: 0 additions & 15 deletions apps/meteor/app/webdav/client/index.js

This file was deleted.

20 changes: 0 additions & 20 deletions apps/meteor/app/webdav/client/startup/sync.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
import { MessageReaction as MessageReactionTemplate, MessageReactionEmoji, MessageReactionCounter } from '@rocket.chat/fuselage';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { useTooltipClose, useTooltipOpen, useTranslation } from '@rocket.chat/ui-contexts';
import { useQueryClient } from '@tanstack/react-query';
import { useTooltipClose, useTooltipOpen } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React, { useContext, useRef } from 'react';
import React, { useRef, useContext } from 'react';

import { getEmojiClassNameAndDataTitle } from '../../../../lib/utils/renderEmoji';
import { useGetMessageByID } from '../../../../views/room/contextualBar/Threads/hooks/useGetMessageByID';
import MarkdownText from '../../../MarkdownText';
import { MessageListContext } from '../../list/MessageListContext';
import ReactionTooltip from './ReactionTooltip';

// TODO: replace it with proper usage of i18next plurals
const getTranslationKey = (users: string[], mine: boolean): TranslationKey => {
if (users.length === 0) {
if (mine) {
return 'You_reacted_with';
}
}

if (users.length > 10) {
if (mine) {
return 'You_users_and_more_Reacted_with';
}
return 'Users_and_more_reacted_with';
}

if (mine) {
return 'You_and_users_Reacted_with';
}
return 'Users_reacted_with';
};

type ReactionProps = {
hasReacted: (name: string) => boolean;
counter: number;
Expand All @@ -41,54 +18,15 @@ type ReactionProps = {
};

const Reaction = ({ hasReacted, counter, name, names, messageId, ...props }: ReactionProps): ReactElement => {
const t = useTranslation();
const ref = useRef<HTMLDivElement>(null);
const openTooltip = useTooltipOpen();
const closeTooltip = useTooltipClose();
const { showRealName, username } = useContext(MessageListContext);

const mine = hasReacted(name);

const key = getTranslationKey(names, mine);

const emojiProps = getEmojiClassNameAndDataTitle(name);

const getMessage = useGetMessageByID();

const queryClient = useQueryClient();

const getNames = async () => {
return queryClient.fetchQuery(
['chat.getMessage', 'reactions', messageId, names],
async () => {
// This happens if the only reaction is from the current user
if (!names.length) {
return [];
}

if (!showRealName) {
return names;
}

const data = await getMessage(messageId);

const { reactions } = data;
if (!reactions) {
return [];
}

if (username) {
const index = reactions[name].usernames.indexOf(username);
index >= 0 && reactions[name].names?.splice(index, 1);
return (reactions[name].names || names).filter(Boolean);
}

return reactions[name].names || names;
},
{ staleTime: 1000 * 60 * 5 },
);
};

return (
<MessageReactionTemplate
ref={ref}
Expand All @@ -102,17 +40,15 @@ const Reaction = ({ hasReacted, counter, name, names, messageId, ...props }: Rea
e.stopPropagation();
e.preventDefault();

const users = await getNames();

ref.current &&
openTooltip(
<MarkdownText
content={t(key, {
counter: names.length > 10 ? names.length - 10 : names.length,
users: users?.slice(0, 10).join(', ') || '',
emoji: name,
})}
variant='inline'
<ReactionTooltip
emojiName={name}
usernames={names}
mine={mine}
messageId={messageId}
showRealName={showRealName}
username={username}
/>,
ref.current,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { useTranslation } from '@rocket.chat/ui-contexts';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';
import React from 'react';

import { useGetMessageByID } from '../../../../views/room/contextualBar/Threads/hooks/useGetMessageByID';
import MarkdownText from '../../../MarkdownText';

type ReactionTooltipProps = {
emojiName: string;
usernames: string[];
username: string | undefined;
mine: boolean;
showRealName: boolean;
messageId: string;
};

const getTranslationKey = (users: string[], mine: boolean): TranslationKey => {
if (users.length === 0) {
if (mine) {
return 'You_reacted_with';
}
}

if (users.length > 10) {
if (mine) {
return 'You_users_and_more_Reacted_with';
}
return 'Users_and_more_reacted_with';
}

if (mine) {
return 'You_and_users_Reacted_with';
}
return 'Users_reacted_with';
};

const ReactionTooltip = ({ emojiName, usernames, mine, messageId, showRealName, username }: ReactionTooltipProps) => {
const t = useTranslation();

const key = getTranslationKey(usernames, mine);

const getMessage = useGetMessageByID();

const { data: users } = useQuery(
['chat.getMessage', 'reactions', messageId, usernames],
async () => {
// This happens if the only reaction is from the current user
if (!usernames.length) {
return [];
}

if (!showRealName) {
return usernames;
}

const data = await getMessage(messageId);

const { reactions } = data;

if (!reactions) {
return [];
}

if (username) {
const index = reactions[emojiName].usernames.indexOf(username);
index >= 0 && reactions[emojiName].names?.splice(index, 1);
return (reactions[emojiName].names || usernames).filter(Boolean);
}

return reactions[emojiName].names || usernames;
},
{ staleTime: 1000 * 60 * 5 },
);

return (
<MarkdownText
content={t(key, {
counter: usernames.length > 10 ? usernames.length - 10 : usernames.length,
users: users?.slice(0, 10).join(', ') || '',
emoji: emojiName,
})}
variant='inline'
/>
);
};

export default ReactionTooltip;
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useAutoTranslate } from '../../../views/room/MessageList/hooks/useAutoT
import { useChat } from '../../../views/room/contexts/ChatContext';
import { useRoomToolbox } from '../../../views/room/contexts/RoomToolboxContext';
import MessageActionMenu from './MessageActionMenu';
import { useWebDAVMessageAction } from './useWebDAVMessageAction';

const getMessageContext = (message: IMessage, room: IRoom, context?: MessageActionContext): MessageActionContext => {
if (context) {
Expand Down Expand Up @@ -72,6 +73,9 @@ const MessageToolbar = ({

const { messageToolbox: hiddenActions } = useLayoutHiddenActions();

// TODO: move this to another place
useWebDAVMessageAction();

const actionsQueryResult = useQuery(['rooms', room._id, 'messages', message._id, 'actions'] as const, async () => {
const props = { message, room, user, subscription, settings: mapSettings, chat };

Expand Down
Loading

0 comments on commit 8fa6543

Please sign in to comment.