Chat List: Hide panels in forum list (#6706)
This commit is contained in:
parent
ee452ef474
commit
68fd459756
@ -6,7 +6,7 @@ import type { ApiPromoData, ApiSession } from '../../../../api/types';
|
|||||||
|
|
||||||
import { FRESH_AUTH_PERIOD } from '../../../../config';
|
import { FRESH_AUTH_PERIOD } from '../../../../config';
|
||||||
import { requestMutation } from '../../../../lib/fasterdom/fasterdom';
|
import { requestMutation } from '../../../../lib/fasterdom/fasterdom';
|
||||||
import { selectIsCurrentUserFrozen } from '../../../../global/selectors';
|
import { selectIsCurrentUserFrozen, selectIsForumPanelOpen } from '../../../../global/selectors';
|
||||||
import buildClassName from '../../../../util/buildClassName';
|
import buildClassName from '../../../../util/buildClassName';
|
||||||
import { getServerTime } from '../../../../util/serverTime';
|
import { getServerTime } from '../../../../util/serverTime';
|
||||||
import { REM } from '../../../common/helpers/mediaDimensions';
|
import { REM } from '../../../common/helpers/mediaDimensions';
|
||||||
@ -32,11 +32,11 @@ type StateProps = {
|
|||||||
sessions: Record<string, ApiSession>;
|
sessions: Record<string, ApiSession>;
|
||||||
promoData?: ApiPromoData;
|
promoData?: ApiPromoData;
|
||||||
isAccountFrozen?: boolean;
|
isAccountFrozen?: boolean;
|
||||||
|
isForumPanelOpen?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TOP_MARGIN = 0.5 * REM;
|
|
||||||
const ITEM_MARGIN = 0.25 * REM;
|
const ITEM_MARGIN = 0.25 * REM;
|
||||||
const BOTTOM_MARGIN = 0.25 * REM;
|
const BOTTOM_MARGIN = 0.5 * REM;
|
||||||
const FALLBACK_PANE_STATE = { height: 0 };
|
const FALLBACK_PANE_STATE = { height: 0 };
|
||||||
|
|
||||||
const ChatListPanes = ({
|
const ChatListPanes = ({
|
||||||
@ -44,6 +44,7 @@ const ChatListPanes = ({
|
|||||||
sessions,
|
sessions,
|
||||||
promoData,
|
promoData,
|
||||||
isAccountFrozen,
|
isAccountFrozen,
|
||||||
|
isForumPanelOpen,
|
||||||
onHeightChange,
|
onHeightChange,
|
||||||
}: OwnProps & StateProps) => {
|
}: OwnProps & StateProps) => {
|
||||||
const [getUnconfirmedSessionHeight, setUnconfirmedSessionHeight] = useSignal<PaneState>(FALLBACK_PANE_STATE);
|
const [getUnconfirmedSessionHeight, setUnconfirmedSessionHeight] = useSignal<PaneState>(FALLBACK_PANE_STATE);
|
||||||
@ -73,9 +74,9 @@ const ChatListPanes = ({
|
|||||||
return sessionsArray.find((session) => session.isUnconfirmed);
|
return sessionsArray.find((session) => session.isUnconfirmed);
|
||||||
}, [sessions]);
|
}, [sessions]);
|
||||||
|
|
||||||
const canShowUnconfirmedSession = !isAccountFrozen && unconfirmedSession;
|
const canShowUnconfirmedSession = !isAccountFrozen && !isForumPanelOpen && unconfirmedSession;
|
||||||
const canShowSuggestions = !isAccountFrozen && !unconfirmedSession && promoData;
|
const canShowSuggestions = !isAccountFrozen && !isForumPanelOpen && !unconfirmedSession && promoData;
|
||||||
const canShowGiftAuctions = !isAccountFrozen;
|
const canShowGiftAuctions = !isAccountFrozen && !isForumPanelOpen;
|
||||||
|
|
||||||
useSignalEffect(() => {
|
useSignalEffect(() => {
|
||||||
const unconfirmedSessionHeight = getUnconfirmedSessionHeight();
|
const unconfirmedSessionHeight = getUnconfirmedSessionHeight();
|
||||||
@ -85,7 +86,6 @@ const ChatListPanes = ({
|
|||||||
|
|
||||||
// Keep in sync with the order of the panes in the DOM
|
// Keep in sync with the order of the panes in the DOM
|
||||||
const stateArray = [
|
const stateArray = [
|
||||||
{ height: TOP_MARGIN, isSpacer: true },
|
|
||||||
unconfirmedSessionHeight,
|
unconfirmedSessionHeight,
|
||||||
frozenAccountHeight,
|
frozenAccountHeight,
|
||||||
giftAuctionHeight,
|
giftAuctionHeight,
|
||||||
@ -96,7 +96,7 @@ const ChatListPanes = ({
|
|||||||
|
|
||||||
const isFirstRender = isFirstRenderRef.current;
|
const isFirstRender = isFirstRenderRef.current;
|
||||||
const totalHeight = stateArray.reduce((acc, state) => acc + state.height, 0);
|
const totalHeight = stateArray.reduce((acc, state) => acc + state.height, 0);
|
||||||
const panelsHeight = totalHeight - TOP_MARGIN - BOTTOM_MARGIN;
|
const panelsHeight = totalHeight - BOTTOM_MARGIN;
|
||||||
|
|
||||||
onHeightChange(panelsHeight !== 0 ? totalHeight : 0);
|
onHeightChange(panelsHeight !== 0 ? totalHeight : 0);
|
||||||
|
|
||||||
@ -151,6 +151,7 @@ const ChatListPanes = ({
|
|||||||
export default memo(withGlobal<OwnProps>(
|
export default memo(withGlobal<OwnProps>(
|
||||||
(global): Complete<StateProps> => {
|
(global): Complete<StateProps> => {
|
||||||
return {
|
return {
|
||||||
|
isForumPanelOpen: selectIsForumPanelOpen(global),
|
||||||
sessions: global.activeSessions.byHash,
|
sessions: global.activeSessions.byHash,
|
||||||
promoData: global.promoData,
|
promoData: global.promoData,
|
||||||
isAccountFrozen: selectIsCurrentUserFrozen(global),
|
isAccountFrozen: selectIsCurrentUserFrozen(global),
|
||||||
|
|||||||
@ -149,7 +149,7 @@ export function applyAnimationState({
|
|||||||
|
|
||||||
const apply = () => {
|
const apply = () => {
|
||||||
setExtraStyles(element, {
|
setExtraStyles(element, {
|
||||||
transform: `translateY(${state.isOpen ? shiftPx : `calc(${shiftPx} - 100%)`})`,
|
transform: `translateY(${state.isOpen ? shiftPx : `calc(${shiftPx} - 100% - 0.5rem)`})`,
|
||||||
zIndex: String(-i),
|
zIndex: String(-i),
|
||||||
transition: noTransition ? 'none' : '',
|
transition: noTransition ? 'none' : '',
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user