Skip to content

Commit

Permalink
Merge pull request #3109 from yougotwill/fix/ses-1945/admins_clear_re…
Browse files Browse the repository at this point in the history
…actions

Fix 'clear all' reactions in communities
  • Loading branch information
Bilb authored May 22, 2024
2 parents 71436ea + 70a9874 commit 6282ed6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
5 changes: 0 additions & 5 deletions stylesheets/_modules.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
.module-contact-name__profile-number.italic {
font-style: italic;
}

.module-contact-name.compact {
display: block;
}

// Module: Message

.module-message__error-container {
Expand Down
5 changes: 2 additions & 3 deletions ts/components/conversation/ContactName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ type Props = {
profileName?: string | null;
module?: string;
boldProfileName?: boolean;
compact?: boolean;
shouldShowPubkey: boolean;
};

export const ContactName = (props: Props) => {
const { pubkey, name, profileName, module, boldProfileName, compact, shouldShowPubkey } = props;
const { pubkey, name, profileName, module, boldProfileName, shouldShowPubkey } = props;
const prefix = module || 'module-contact-name';

const convoName = useNicknameOrProfileNameOrShortenedPubkey(pubkey);
Expand All @@ -43,7 +42,7 @@ export const ContactName = (props: Props) => {

return (
<span
className={classNames(prefix, compact && 'compact')}
className={classNames(prefix)}
dir="auto"
data-testid={`${prefix}__profile-name`}
style={{
Expand Down
3 changes: 1 addition & 2 deletions ts/components/conversation/message/message-content/Quote.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from 'classnames';
import React, { useState } from 'react';
import { noop } from 'lodash';
import React, { useState } from 'react';

import * as MIME from '../../../../types/MIME';
import * as GoogleChrome from '../../../../util/GoogleChrome';
Expand Down Expand Up @@ -291,7 +291,6 @@ const QuoteAuthor = (props: QuoteAuthorProps) => {
pubkey={PubKey.shorten(author)}
name={authorName}
profileName={authorProfileName}
compact={true}
shouldShowPubkey={Boolean(props.showPubkeyForAuthor)}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const QuoteAuthor = (props: QuoteAuthorProps) => {
<ContactName
pubkey={PubKey.shorten(author)}
name={authorName}
compact={true}
shouldShowPubkey={Boolean(authorName && !isMe && isPublic)}
/>
</StyledQuoteAuthor>
Expand Down
23 changes: 16 additions & 7 deletions ts/components/dialog/ReactListModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from '../../state/ducks/modalDialog';
import {
useSelectedIsPublic,
useSelectedWeAreAdmin,
useSelectedWeAreModerator,
} from '../../state/selectors/selectedConversation';
import { SortedReactionList } from '../../types/Reaction';
Expand Down Expand Up @@ -50,6 +51,11 @@ const StyledSendersContainer = styled(Flex)`
padding: 0 16px 16px;
`;

const StyledContactContainer = styled.span`
text-overflow: ellipsis;
overflow: hidden;
`;

const StyledReactionBar = styled(Flex)`
width: 100%;
margin: 12px 0 20px 4px;
Expand Down Expand Up @@ -132,7 +138,7 @@ const ReactionSenders = (props: ReactionSendersProps) => {
justifyContent={'space-between'}
alignItems={'center'}
>
<Flex container={true} alignItems={'center'}>
<Flex container={true} alignItems={'center'} style={{ overflow: 'hidden' }}>
<Avatar
size={AvatarSize.XS}
pubkey={sender}
Expand All @@ -143,11 +149,13 @@ const ReactionSenders = (props: ReactionSendersProps) => {
{sender === me ? (
window.i18n('you')
) : (
<ContactName
pubkey={sender}
module="module-conversation__user"
shouldShowPubkey={false}
/>
<StyledContactContainer>
<ContactName
pubkey={sender}
module="module-conversation__user"
shouldShowPubkey={false}
/>
</StyledContactContainer>
)}
</Flex>
{sender === me && (
Expand Down Expand Up @@ -231,6 +239,7 @@ export const ReactListModal = (props: Props) => {

const msgProps = useMessageReactsPropsById(messageId);
const isPublic = useSelectedIsPublic();
const weAreAdmin = useSelectedWeAreAdmin();
const weAreModerator = useSelectedWeAreModerator();
const me = UserUtils.getOurPubKeyStrFromCache();

Expand Down Expand Up @@ -362,7 +371,7 @@ export const ReactListModal = (props: Props) => {
</>
)}
</p>
{isPublic && weAreModerator && (
{isPublic && (weAreAdmin || weAreModerator) && (
<SessionButton
text={window.i18n('clearAll')}
buttonColor={SessionButtonColor.Danger}
Expand Down

0 comments on commit 6282ed6

Please sign in to comment.