|
|
@ -9,9 +9,7 @@ function showTimerOptions(
|
|
|
|
isKickedFromGroup: boolean,
|
|
|
|
isKickedFromGroup: boolean,
|
|
|
|
isBlocked: boolean
|
|
|
|
isBlocked: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return (
|
|
|
|
return !isPublic && !isRss && !isKickedFromGroup && !isBlocked;
|
|
|
|
Boolean(!isPublic) && Boolean(!isRss) && !isKickedFromGroup && !isBlocked
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showMemberMenu(
|
|
|
|
function showMemberMenu(
|
|
|
@ -19,7 +17,7 @@ function showMemberMenu(
|
|
|
|
isRss: boolean,
|
|
|
|
isRss: boolean,
|
|
|
|
isGroup: boolean
|
|
|
|
isGroup: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return Boolean(!isPublic) && Boolean(!isRss) && isGroup;
|
|
|
|
return !isPublic && !isRss && isGroup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showSafetyNumber(
|
|
|
|
function showSafetyNumber(
|
|
|
@ -28,7 +26,7 @@ function showSafetyNumber(
|
|
|
|
isGroup: boolean,
|
|
|
|
isGroup: boolean,
|
|
|
|
isMe: boolean
|
|
|
|
isMe: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return Boolean(!isPublic) && Boolean(!isRss) && !isGroup && !isMe;
|
|
|
|
return !isPublic && !isRss && !isGroup && !isMe;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showResetSession(
|
|
|
|
function showResetSession(
|
|
|
@ -36,84 +34,72 @@ function showResetSession(
|
|
|
|
isRss: boolean,
|
|
|
|
isRss: boolean,
|
|
|
|
isGroup: boolean
|
|
|
|
isGroup: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return Boolean(!isPublic) && Boolean(!isRss) && Boolean(!isGroup);
|
|
|
|
return !isPublic && !isRss && !isGroup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showBlock(
|
|
|
|
function showBlock(isMe: boolean, isPrivate: boolean): boolean {
|
|
|
|
isMe: boolean | undefined,
|
|
|
|
return !isMe && isPrivate;
|
|
|
|
isPrivate: boolean | undefined
|
|
|
|
|
|
|
|
): boolean {
|
|
|
|
|
|
|
|
return Boolean(!isMe) && Boolean(isPrivate);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showClearNickname(
|
|
|
|
function showClearNickname(
|
|
|
|
isPublic: boolean | undefined,
|
|
|
|
isPublic: boolean,
|
|
|
|
isRss: boolean | undefined,
|
|
|
|
isRss: boolean,
|
|
|
|
isMe: boolean | undefined,
|
|
|
|
isMe: boolean,
|
|
|
|
hasNickname: boolean | undefined
|
|
|
|
hasNickname: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return (
|
|
|
|
return !isPublic && !isRss && !isMe && hasNickname;
|
|
|
|
Boolean(!isPublic) &&
|
|
|
|
|
|
|
|
Boolean(!isRss) &&
|
|
|
|
|
|
|
|
Boolean(!isMe) &&
|
|
|
|
|
|
|
|
Boolean(hasNickname)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showCopyId(
|
|
|
|
function showDeleteMessages(isPublic: boolean): boolean {
|
|
|
|
isPublic: boolean | undefined,
|
|
|
|
return !isPublic;
|
|
|
|
isRss: boolean | undefined
|
|
|
|
}
|
|
|
|
): boolean {
|
|
|
|
|
|
|
|
return Boolean(!isPublic) && Boolean(!isRss);
|
|
|
|
function showCopyId(isPublic: boolean, isRss: boolean | undefined): boolean {
|
|
|
|
|
|
|
|
return !isPublic && !isRss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showDeleteContact(
|
|
|
|
function showDeleteContact(
|
|
|
|
isMe: boolean | undefined,
|
|
|
|
isMe: boolean,
|
|
|
|
isClosable: boolean | undefined,
|
|
|
|
isClosable: boolean,
|
|
|
|
isGroup: boolean | undefined,
|
|
|
|
isGroup: boolean,
|
|
|
|
isPublic: boolean | undefined,
|
|
|
|
isPublic: boolean,
|
|
|
|
isRss: boolean | undefined
|
|
|
|
isRss: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return (
|
|
|
|
return !isMe && isClosable && !!(!isGroup || isPublic || isRss);
|
|
|
|
Boolean(!isMe) && Boolean(isClosable) && !!(!isGroup || isPublic || isRss)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showAddModerators(
|
|
|
|
function showAddModerators(
|
|
|
|
amMod: boolean | undefined,
|
|
|
|
amMod: boolean,
|
|
|
|
isKickedFromGroup: boolean | undefined
|
|
|
|
isKickedFromGroup: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return Boolean(!isKickedFromGroup) && Boolean(amMod);
|
|
|
|
return !isKickedFromGroup && amMod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showRemoveModerators(
|
|
|
|
function showRemoveModerators(
|
|
|
|
amMod: boolean | undefined,
|
|
|
|
amMod: boolean,
|
|
|
|
isKickedFromGroup: boolean | undefined
|
|
|
|
isKickedFromGroup: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return Boolean(!isKickedFromGroup) && Boolean(amMod);
|
|
|
|
return !isKickedFromGroup && amMod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showUpdateGroupName(
|
|
|
|
function showUpdateGroupName(
|
|
|
|
amMod: boolean | undefined,
|
|
|
|
amMod: boolean,
|
|
|
|
isKickedFromGroup: boolean | undefined
|
|
|
|
isKickedFromGroup: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return Boolean(!isKickedFromGroup) && Boolean(amMod);
|
|
|
|
return !isKickedFromGroup && amMod;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showLeaveGroup(
|
|
|
|
function showLeaveGroup(
|
|
|
|
isKickedFromGroup: boolean | undefined,
|
|
|
|
isKickedFromGroup: boolean,
|
|
|
|
isGroup: boolean | undefined,
|
|
|
|
isGroup: boolean,
|
|
|
|
isPublic: boolean | undefined,
|
|
|
|
isPublic: boolean,
|
|
|
|
isRss: boolean | undefined
|
|
|
|
isRss: boolean
|
|
|
|
): boolean {
|
|
|
|
): boolean {
|
|
|
|
return Boolean(!isKickedFromGroup) && Boolean(isGroup) && !isPublic && !isRss;
|
|
|
|
return !isKickedFromGroup && isGroup && !isPublic && !isRss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function showInviteContact(
|
|
|
|
function showInviteContact(isGroup: boolean, isPublic: boolean): boolean {
|
|
|
|
isGroup: boolean | undefined,
|
|
|
|
return isGroup && isPublic;
|
|
|
|
isPublic: boolean | undefined
|
|
|
|
|
|
|
|
): boolean {
|
|
|
|
|
|
|
|
return Boolean(isGroup) && Boolean(isPublic);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Menu items standardized */
|
|
|
|
/** Menu items standardized */
|
|
|
@ -124,7 +110,7 @@ export function getInviteContactMenuItem(
|
|
|
|
action: any,
|
|
|
|
action: any,
|
|
|
|
i18n: LocalizerType
|
|
|
|
i18n: LocalizerType
|
|
|
|
): JSX.Element | null {
|
|
|
|
): JSX.Element | null {
|
|
|
|
if (showInviteContact(isGroup, isPublic)) {
|
|
|
|
if (showInviteContact(Boolean(isGroup), Boolean(isPublic))) {
|
|
|
|
return <MenuItem onClick={action}>{i18n('inviteContacts')}</MenuItem>;
|
|
|
|
return <MenuItem onClick={action}>{i18n('inviteContacts')}</MenuItem>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -139,7 +125,15 @@ export function getDeleteContactMenuItem(
|
|
|
|
action: any,
|
|
|
|
action: any,
|
|
|
|
i18n: LocalizerType
|
|
|
|
i18n: LocalizerType
|
|
|
|
): JSX.Element | null {
|
|
|
|
): JSX.Element | null {
|
|
|
|
if (showDeleteContact(isMe, isClosable, isGroup, isPublic, isRss)) {
|
|
|
|
if (
|
|
|
|
|
|
|
|
showDeleteContact(
|
|
|
|
|
|
|
|
Boolean(isMe),
|
|
|
|
|
|
|
|
Boolean(isClosable),
|
|
|
|
|
|
|
|
Boolean(isGroup),
|
|
|
|
|
|
|
|
Boolean(isPublic),
|
|
|
|
|
|
|
|
Boolean(isRss)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
) {
|
|
|
|
if (isPublic) {
|
|
|
|
if (isPublic) {
|
|
|
|
return <MenuItem onClick={action}>{i18n('leaveOpenGroup')}</MenuItem>;
|
|
|
|
return <MenuItem onClick={action}>{i18n('leaveOpenGroup')}</MenuItem>;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -156,7 +150,14 @@ export function getLeaveGroupMenuItem(
|
|
|
|
action: any,
|
|
|
|
action: any,
|
|
|
|
i18n: LocalizerType
|
|
|
|
i18n: LocalizerType
|
|
|
|
): JSX.Element | null {
|
|
|
|
): JSX.Element | null {
|
|
|
|
if (showLeaveGroup(isKickedFromGroup, isGroup, isPublic, isRss)) {
|
|
|
|
if (
|
|
|
|
|
|
|
|
showLeaveGroup(
|
|
|
|
|
|
|
|
Boolean(isKickedFromGroup),
|
|
|
|
|
|
|
|
Boolean(isGroup),
|
|
|
|
|
|
|
|
Boolean(isPublic),
|
|
|
|
|
|
|
|
Boolean(isRss)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
) {
|
|
|
|
return <MenuItem onClick={action}>{i18n('leaveClosedGroup')}</MenuItem>;
|
|
|
|
return <MenuItem onClick={action}>{i18n('leaveClosedGroup')}</MenuItem>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -168,7 +169,7 @@ export function getUpdateGroupNameMenuItem(
|
|
|
|
action: any,
|
|
|
|
action: any,
|
|
|
|
i18n: LocalizerType
|
|
|
|
i18n: LocalizerType
|
|
|
|
): JSX.Element | null {
|
|
|
|
): JSX.Element | null {
|
|
|
|
if (showUpdateGroupName(amMod, isKickedFromGroup)) {
|
|
|
|
if (showUpdateGroupName(Boolean(amMod), Boolean(isKickedFromGroup))) {
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<MenuItem onClick={action}>{i18n('editGroupNameOrPicture')}</MenuItem>
|
|
|
|
<MenuItem onClick={action}>{i18n('editGroupNameOrPicture')}</MenuItem>
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -182,7 +183,7 @@ export function getRemoveModeratorsMenuItem(
|
|
|
|
action: any,
|
|
|
|
action: any,
|
|
|
|
i18n: LocalizerType
|
|
|
|
i18n: LocalizerType
|
|
|
|
): JSX.Element | null {
|
|
|
|
): JSX.Element | null {
|
|
|
|
if (showRemoveModerators(amMod, isKickedFromGroup)) {
|
|
|
|
if (showRemoveModerators(Boolean(amMod), Boolean(isKickedFromGroup))) {
|
|
|
|
return <MenuItem onClick={action}>{i18n('removeModerators')}</MenuItem>;
|
|
|
|
return <MenuItem onClick={action}>{i18n('removeModerators')}</MenuItem>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -194,7 +195,7 @@ export function getAddModeratorsMenuItem(
|
|
|
|
action: any,
|
|
|
|
action: any,
|
|
|
|
i18n: LocalizerType
|
|
|
|
i18n: LocalizerType
|
|
|
|
): JSX.Element | null {
|
|
|
|
): JSX.Element | null {
|
|
|
|
if (showAddModerators(amMod, isKickedFromGroup)) {
|
|
|
|
if (showAddModerators(Boolean(amMod), Boolean(isKickedFromGroup))) {
|
|
|
|
return <MenuItem onClick={action}>{i18n('addModerators')}</MenuItem>;
|
|
|
|
return <MenuItem onClick={action}>{i18n('addModerators')}</MenuItem>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -207,8 +208,8 @@ export function getCopyIdMenuItem(
|
|
|
|
action: any,
|
|
|
|
action: any,
|
|
|
|
i18n: LocalizerType
|
|
|
|
i18n: LocalizerType
|
|
|
|
): JSX.Element | null {
|
|
|
|
): JSX.Element | null {
|
|
|
|
if (showCopyId(isPublic, isRss)) {
|
|
|
|
if (showCopyId(Boolean(isPublic), Boolean(isRss))) {
|
|
|
|
const copyIdLabel = isGroup ? i18n('copyChatId') : i18n('copyPublicKey');
|
|
|
|
const copyIdLabel = i18n('editMenuCopy');
|
|
|
|
return <MenuItem onClick={action}>{copyIdLabel}</MenuItem>;
|
|
|
|
return <MenuItem onClick={action}>{copyIdLabel}</MenuItem>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -332,3 +333,14 @@ export function getClearNicknameMenuItem(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function getDeleteMessagesMenuItem(
|
|
|
|
|
|
|
|
isPublic: boolean | undefined,
|
|
|
|
|
|
|
|
action: any,
|
|
|
|
|
|
|
|
i18n: LocalizerType
|
|
|
|
|
|
|
|
): JSX.Element | null {
|
|
|
|
|
|
|
|
if (showDeleteMessages(Boolean(isPublic))) {
|
|
|
|
|
|
|
|
return <MenuItem onClick={action}>{i18n('deleteMessages')}</MenuItem>;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|