Pinned List: Display "Unpin" button only for admins (#3363)
This commit is contained in:
parent
4c9815a394
commit
e82b6110ac
@ -53,6 +53,8 @@ import {
|
|||||||
isChatGroup,
|
isChatGroup,
|
||||||
isChatSuperGroup,
|
isChatSuperGroup,
|
||||||
isUserId,
|
isUserId,
|
||||||
|
isUserRightBanned,
|
||||||
|
getHasAdminRight,
|
||||||
} from '../../global/helpers';
|
} from '../../global/helpers';
|
||||||
import calculateMiddleFooterTransforms from './helpers/calculateMiddleFooterTransforms';
|
import calculateMiddleFooterTransforms from './helpers/calculateMiddleFooterTransforms';
|
||||||
import captureEscKeyListener from '../../util/captureEscKeyListener';
|
import captureEscKeyListener from '../../util/captureEscKeyListener';
|
||||||
@ -139,6 +141,7 @@ type StateProps = {
|
|||||||
shouldSendJoinRequest?: boolean;
|
shouldSendJoinRequest?: boolean;
|
||||||
pinnedIds?: number[];
|
pinnedIds?: number[];
|
||||||
topMessageId?: number;
|
topMessageId?: number;
|
||||||
|
canUnpin?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function isImage(item: DataTransferItem) {
|
function isImage(item: DataTransferItem) {
|
||||||
@ -192,6 +195,7 @@ function MiddleColumn({
|
|||||||
shouldLoadFullChat,
|
shouldLoadFullChat,
|
||||||
pinnedIds,
|
pinnedIds,
|
||||||
topMessageId,
|
topMessageId,
|
||||||
|
canUnpin,
|
||||||
}: OwnProps & StateProps) {
|
}: OwnProps & StateProps) {
|
||||||
const {
|
const {
|
||||||
openChat,
|
openChat,
|
||||||
@ -526,7 +530,7 @@ function MiddleColumn({
|
|||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isPinnedMessageList && (
|
{isPinnedMessageList && canUnpin && (
|
||||||
<div className="middle-column-footer-button-container" dir={lang.isRtl ? 'rtl' : undefined}>
|
<div className="middle-column-footer-button-container" dir={lang.isRtl ? 'rtl' : undefined}>
|
||||||
<Button
|
<Button
|
||||||
size="tiny"
|
size="tiny"
|
||||||
@ -720,6 +724,13 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const isCommentThread = threadId !== MAIN_THREAD_ID && !chat?.isForum;
|
const isCommentThread = threadId !== MAIN_THREAD_ID && !chat?.isForum;
|
||||||
const topMessageId = isCommentThread ? selectThreadTopMessageId(global, chatId, threadId) : undefined;
|
const topMessageId = isCommentThread ? selectThreadTopMessageId(global, chatId, threadId) : undefined;
|
||||||
|
|
||||||
|
const canUnpin = chat && (
|
||||||
|
isPrivate || (
|
||||||
|
chat?.isCreator || (!isChannel && !isUserRightBanned(chat, 'pinMessages'))
|
||||||
|
|| getHasAdminRight(chat, 'pinMessages')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
chatId,
|
chatId,
|
||||||
@ -751,6 +762,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
shouldLoadFullChat,
|
shouldLoadFullChat,
|
||||||
pinnedIds,
|
pinnedIds,
|
||||||
topMessageId,
|
topMessageId,
|
||||||
|
canUnpin,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
)(MiddleColumn));
|
)(MiddleColumn));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user