diff --git a/ts/components/basic/SessionRadio.tsx b/ts/components/basic/SessionRadio.tsx index e8e346f27..48b44dec1 100644 --- a/ts/components/basic/SessionRadio.tsx +++ b/ts/components/basic/SessionRadio.tsx @@ -1,5 +1,5 @@ import React, { ChangeEvent } from 'react'; -import styled from 'styled-components'; +import styled, { CSSProperties } from 'styled-components'; import { Flex } from './Flex'; const StyledInput = styled.input<{ @@ -54,10 +54,20 @@ type SessionRadioProps = { beforeMargins?: string; onClick?: (value: string) => void; disabled?: boolean; + style?: CSSProperties; }; export const SessionRadio = (props: SessionRadioProps) => { - const { label, inputName, value, active, onClick, beforeMargins, disabled = false } = props; + const { + label, + inputName, + value, + active, + onClick, + beforeMargins, + disabled = false, + style, + } = props; const clickHandler = (e: ChangeEvent) => { if (!disabled && onClick) { @@ -71,7 +81,7 @@ export const SessionRadio = (props: SessionRadioProps) => { const outlineOffset = 2; return ( - + ` export const StyledText = styled.span` font-size: var(--font-size-md); font-weight: 500; - margin-inline-start: var(--margins-lg); - margin-inline-end: var(--margins-lg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -38,16 +36,14 @@ const StyledRoundedPanelButtonGroup = styled.div` overflow: hidden; background: var(--right-panel-item-background-color); border-radius: 16px; - padding: var(--margins-lg); + padding: 0 var(--margins-lg) var(--margins-xs); margin: 0 var(--margins-lg); width: -webkit-fill-available; `; const PanelButtonContainer = styled.div` overflow: auto; - // TODO clear - /* min-height: 50px; */ - min-height: 40px; + min-height: 65px; max-height: 100%; `; @@ -75,8 +71,7 @@ const StyledPanelButton = styled.button<{ flex-shrink: 0; flex-grow: 1; font-family: var(--font-default); - padding: 0px var(--margins-sm); - min-height: 50px; + height: 65px; width: 100%; transition: var(--default-duration); color: ${props => (props.disabled ? 'var(--disabled-color)' : 'inherit')}; @@ -114,8 +109,11 @@ export const PanelButton = (props: PanelButtonProps) => { const StyledSubtitle = styled.p<{ color?: string }>` font-size: var(--font-size-xs); - margin: 0; - text-align: initial; + line-height: 1.1; + margin-top: 0; + margin-bottom: 0; + /* TODO needs RTL support */ + text-align: left; ${props => props.color && `color: ${props.color};`} `; @@ -126,7 +124,7 @@ export const PanelButtonText = (props: { text: string; subtitle?: string; color? width={'100%'} flexDirection={'column'} alignItems={'flex-start'} - margin="0 var(--margins-lg) 0 var(--margins-lg)" + margin="0 var(--margins-lg) 0 0" minWidth="0" > {props.text} diff --git a/ts/components/buttons/PanelIconButton.tsx b/ts/components/buttons/PanelIconButton.tsx index f47c6e687..79d5f32d6 100644 --- a/ts/components/buttons/PanelIconButton.tsx +++ b/ts/components/buttons/PanelIconButton.tsx @@ -12,7 +12,8 @@ interface PanelIconButton extends Omit { const IconContainer = styled.div` flex-shrink: 0; - width: var(--toggle-width); + margin: 0 var(--margins-lg) 0 var(--margins-sm); + padding: 0; `; export const PanelIconButton = (props: PanelIconButton) => { @@ -22,7 +23,7 @@ export const PanelIconButton = (props: PanelIconButton) => { - + diff --git a/ts/components/buttons/PanelRadioButton.tsx b/ts/components/buttons/PanelRadioButton.tsx index af7936bb3..6f0cb2c41 100644 --- a/ts/components/buttons/PanelRadioButton.tsx +++ b/ts/components/buttons/PanelRadioButton.tsx @@ -7,13 +7,6 @@ const StyledPanelButton = styled(PanelButton)` padding-top: var(--margins-lg); padding-bottom: var(--margins-lg); text-align: left; - - div { - span { - margin-inline-start: 0; - margin-inline-end: 0; - } - } `; const StyledCheckContainer = styled.div` diff --git a/ts/components/conversation/SessionConversation.tsx b/ts/components/conversation/SessionConversation.tsx index b81fc485a..77dfe2865 100644 --- a/ts/components/conversation/SessionConversation.tsx +++ b/ts/components/conversation/SessionConversation.tsx @@ -250,7 +250,7 @@ export class SessionConversation extends React.Component { // return an empty message view return ; } - // TODOLATER break showMessageDetails & selectionMode into it's own container component so we can use hooks to fetch relevant state from the store + // TODOLATER break selectionMode into it's own container component so we can use hooks to fetch relevant state from the store const selectionMode = selectedMessages.length > 0; const bannerText = diff --git a/ts/components/conversation/header/ConversationHeaderTitle.tsx b/ts/components/conversation/header/ConversationHeaderTitle.tsx index 179f55a7e..d496b846a 100644 --- a/ts/components/conversation/header/ConversationHeaderTitle.tsx +++ b/ts/components/conversation/header/ConversationHeaderTitle.tsx @@ -1,14 +1,13 @@ -import { isNumber } from 'lodash'; +import { isEmpty } from 'lodash'; import React, { useEffect, useMemo, useState } from 'react'; import { useDispatch } from 'react-redux'; +import { useDisappearingMessageSettingText } from '../../../hooks/useParamSelector'; import { useIsRightPanelShowing } from '../../../hooks/useUI'; -import { TimerOptions } from '../../../session/disappearing_messages/timerOptions'; import { closeRightPanel, openRightPanel } from '../../../state/ducks/conversations'; import { resetRightOverlayMode, setRightOverlayMode } from '../../../state/ducks/section'; import { useSelectedConversationDisappearingMode, useSelectedConversationKey, - useSelectedExpireTimer, useSelectedIsGroup, useSelectedIsKickedFromGroup, useSelectedIsNoteToSelf, @@ -47,7 +46,10 @@ export const ConversationHeaderTitle = () => { const members = useSelectedMembers(); const expirationMode = useSelectedConversationDisappearingMode(); - const expireTimer = useSelectedExpireTimer(); + const disappearingMessageSubtitle = useDisappearingMessageSettingText({ + convoId, + abbreviate: true, + }); const [visibleSubtitle, setVisibleSubtitle] = useState( 'disappearingMessages' @@ -81,39 +83,20 @@ export const ConversationHeaderTitle = () => { return null; }, [i18n, isGroup, isKickedFromGroup, isPublic, members.length, subscriberCount]); - // TODO legacy messages support will be removed in a future release - // NOTE If disappearing messages is defined we must show it first - const disappearingMessageSubtitle = useMemo(() => { - const disappearingMessageSettingText = - expirationMode === 'deleteAfterRead' - ? window.i18n('disappearingMessagesModeAfterRead') - : expirationMode === 'deleteAfterSend' - ? window.i18n('disappearingMessagesModeAfterSend') - : expirationMode === 'legacy' - ? isMe || (isGroup && !isPublic) - ? window.i18n('disappearingMessagesModeAfterSend') - : window.i18n('disappearingMessagesModeAfterRead') - : null; - - const abbreviatedExpireTime = isNumber(expireTimer) - ? TimerOptions.getAbbreviated(expireTimer) - : null; - - return expireTimer && disappearingMessageSettingText - ? `${disappearingMessageSettingText}${ - abbreviatedExpireTime ? ` - ${abbreviatedExpireTime}` : '' - }` - : null; - }, [expirationMode, expireTimer, isGroup, isMe, isPublic]); - const handleRightPanelToggle = () => { if (isRightPanelOn) { dispatch(closeRightPanel()); return; } + // NOTE If disappearing messages is defined we must show it first if (visibleSubtitle === 'disappearingMessages') { - dispatch(setRightOverlayMode({ type: 'disappearing_messages', params: null })); + dispatch( + setRightOverlayMode({ + type: 'disappearing_messages', + params: null, + }) + ); } else { dispatch(resetRightOverlayMode()); } @@ -122,7 +105,7 @@ export const ConversationHeaderTitle = () => { useEffect(() => { if (visibleSubtitle !== 'disappearingMessages') { - if (disappearingMessageSubtitle) { + if (!isEmpty(disappearingMessageSubtitle)) { setVisibleSubtitle('disappearingMessages'); } else { setVisibleSubtitle('notifications'); diff --git a/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx b/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx index 7d15923a6..578e22fd1 100644 --- a/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx +++ b/ts/components/conversation/right-panel/overlay/OverlayRightPanelSettings.tsx @@ -7,6 +7,7 @@ import styled from 'styled-components'; import { Data } from '../../../../data/data'; import { SessionIconButton } from '../../../icon'; +import { useDisappearingMessageSettingText } from '../../../../hooks/useParamSelector'; import { useIsRightPanelShowing } from '../../../../hooks/useUI'; import { deleteAllMessagesByConvoIdWithConfirmation, @@ -216,6 +217,10 @@ export const OverlayRightPanelSettings = () => { const isGroup = useSelectedIsGroup(); const isPublic = useSelectedIsPublic(); const weAreAdmin = useSelectedWeAreAdmin(); + const disappearingMessagesSubtitle = useDisappearingMessageSettingText({ + convoId: selectedConvoKey, + separator: ': ', + }); useEffect(() => { let isCancelled = false; @@ -322,7 +327,7 @@ export const OverlayRightPanelSettings = () => { {showUpdateGroupMembersButton && ( { void showUpdateGroupMembersByConvoId(selectedConvoKey); @@ -334,6 +339,7 @@ export const OverlayRightPanelSettings = () => { { dispatch(setRightOverlayMode({ type: 'disappearing_messages', params: null })); }} diff --git a/ts/components/icon/Icons.tsx b/ts/components/icon/Icons.tsx index 86b2d917d..78967591e 100644 --- a/ts/components/icon/Icons.tsx +++ b/ts/components/icon/Icons.tsx @@ -33,7 +33,6 @@ export type SessionIconType = | 'fullscreen' | 'gear' | 'group' - | 'groupMembers' | 'hangup' | 'image' | 'info' @@ -230,13 +229,6 @@ export const icons: Record { label={''} value={theme.id} inputName={'theme-switcher'} + style={{ padding: '0 0 0 var(--margins-lg)' }} /> ))} diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index b71b9be71..2a8734406 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -379,3 +379,44 @@ export function useSortedGroupMembers(convoId: string | undefined): Array