Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3347059
D8709.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D8709.diff
View Options
diff --git a/lib/shared/reaction-utils.js b/lib/shared/reaction-utils.js
--- a/lib/shared/reaction-utils.js
+++ b/lib/shared/reaction-utils.js
@@ -16,23 +16,6 @@
import { type ThreadInfo } from '../types/thread-types.js';
import { useSelector } from '../utils/redux-utils.js';
-function stringForReactionList(reactions: ReactionInfo): string {
- const reactionText = [];
-
- for (const reaction in reactions) {
- const reactionInfo = reactions[reaction];
-
- reactionText.push(reaction);
- const { length: numberOfReacts } = reactionInfo.users;
- if (numberOfReacts <= 1) {
- continue;
- }
- reactionText.push(numberOfReacts > 9 ? '9+' : numberOfReacts.toString());
- }
-
- return reactionText.join(' ');
-}
-
function useViewerAlreadySelectedMessageReactions(
reactions: ReactionInfo,
): $ReadOnlyArray<string> {
@@ -120,7 +103,6 @@
}
export {
- stringForReactionList,
useViewerAlreadySelectedMessageReactions,
useMessageReactionsList,
useCanCreateReactionFromMessage,
diff --git a/lib/shared/reaction-utils.test.js b/lib/shared/reaction-utils.test.js
deleted file mode 100644
--- a/lib/shared/reaction-utils.test.js
+++ /dev/null
@@ -1,158 +0,0 @@
-// @flow
-
-import { stringForReactionList } from './reaction-utils.js';
-import type { ReactionInfo } from '../selectors/chat-selectors.js';
-
-describe('stringForReactionList(reactions: ReactionInfo)', () => {
- it(
- 'should return (👍 3) for a message with three user likes' +
- ' including the viewer',
- () => {
- const messageLikesUsers = [
- { id: '83810', isViewer: true, username: 'ginsu' },
- { id: '86622', isViewer: false, username: 'ashoat' },
- { id: '83889', isViewer: false, username: 'atul' },
- ];
- const messageLikesInfo = {
- users: messageLikesUsers,
- viewerReacted: true,
- };
-
- const reactions: ReactionInfo = {
- '👍': messageLikesInfo,
- };
-
- expect(stringForReactionList(reactions)).toBe('👍 3');
- },
- );
-
- it(
- 'should return (👍 3) for a message with three user likes' +
- ' not including the viewer',
- () => {
- const messageLikesUsers = [
- { id: '83810', isViewer: false, username: 'ginsu' },
- { id: '86622', isViewer: false, username: 'ashoat' },
- { id: '83889', isViewer: false, username: 'atul' },
- ];
- const messageLikesInfo = {
- users: messageLikesUsers,
- viewerReacted: false,
- };
-
- const reactions: ReactionInfo = {
- '👍': messageLikesInfo,
- };
-
- expect(stringForReactionList(reactions)).toBe('👍 3');
- },
- );
-
- it(
- 'should return (👍) for a message with one user like' +
- ' including the viewer',
- () => {
- const messageLikesUsers = [
- { id: '83810', isViewer: false, username: 'ginsu' },
- ];
- const messageLikesInfo = {
- users: messageLikesUsers,
- viewerReacted: true,
- };
-
- const reactions: ReactionInfo = {
- '👍': messageLikesInfo,
- };
-
- expect(stringForReactionList(reactions)).toBe('👍');
- },
- );
-
- it(
- 'should return (👍) for a message with one user like' +
- ' not including the viewer',
- () => {
- const messageLikesUsers = [
- { id: '83810', isViewer: false, username: 'ashoat' },
- ];
- const messageLikesInfo = {
- users: messageLikesUsers,
- viewerReacted: false,
- };
-
- const reactions: ReactionInfo = {
- '👍': messageLikesInfo,
- };
-
- expect(stringForReactionList(reactions)).toBe('👍');
- },
- );
-
- it('should return an empty string for a message no reactions', () => {
- const reactions: ReactionInfo = {};
-
- expect(stringForReactionList(reactions)).toBe('');
- });
-
- it(
- 'should return (👍 😆 3) for a message with one like not including' +
- ' the viewer and three laugh reactions including the viewer',
- () => {
- const messageLikesUsers = [
- { id: '83810', isViewer: false, username: 'varun' },
- ];
- const messageLikesInfo = {
- users: messageLikesUsers,
- viewerReacted: false,
- };
-
- const messageLaughsUsers = [
- { id: '12345', isViewer: true, username: 'ginsu' },
- { id: '67890', isViewer: false, username: 'ashoat' },
- { id: '83889', isViewer: false, username: 'atul' },
- ];
- const messageLaughsInfo = {
- users: messageLaughsUsers,
- viewerReacted: true,
- };
-
- const reactions: ReactionInfo = {
- '👍': messageLikesInfo,
- '😆': messageLaughsInfo,
- };
-
- expect(stringForReactionList(reactions)).toBe('👍 😆 3');
- },
- );
-
- it(
- 'should return (👍 9+) for a message with 12 user likes' +
- ' not including the viewer',
- () => {
- const messageLikesUsers = [
- { id: '86622', isViewer: false, username: 'ginsu' },
- { id: '12345', isViewer: false, username: 'ashoat' },
- { id: '67890', isViewer: false, username: 'atul' },
- { id: '83889', isViewer: false, username: 'varun' },
- { id: '49203', isViewer: false, username: 'tomek' },
- { id: '83029', isViewer: false, username: 'max' },
- { id: '72902', isViewer: false, username: 'jon' },
- { id: '49022', isViewer: false, username: 'mark' },
- { id: '48902', isViewer: false, username: 'kamil' },
- { id: '80922', isViewer: false, username: 'marcin' },
- { id: '12890', isViewer: false, username: 'inka' },
- { id: '67891', isViewer: false, username: 'przemek' },
- ];
- const messageLikesInfo = {
- users: messageLikesUsers,
- viewerReacted: false,
- };
-
- const reactions: ReactionInfo = {
- '👍': messageLikesInfo,
- };
-
- expect(stringForReactionList(reactions)).toBe('👍 9+');
- },
- );
-});
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 10:56 AM (18 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570306
Default Alt Text
D8709.diff (5 KB)
Attached To
Mode
D8709: [web] deprecate stringForReactionList
Attached
Detach File
Event Timeline
Log In to Comment