Add new overview landing page setting (#39074)
This commit is contained in:
1 parent
f6d1795da5
commit
07d099cbf7
15 files changed
+483
-17
No files matched your search
@@ -12,6 +12,8 @@ import classNames from 'classnames';
|
||||
import type { List, Record } from 'immutable';
|
||||
|
||||
import { useAppSelector } from '@/mastodon/store';
|
||||
import { Footer } from 'mastodon/features/custom_homepage/components/footer';
|
||||
import { Header } from 'mastodon/features/custom_homepage/components/header';
|
||||
import { CollapsibleNavigationPanel } from 'mastodon/features/navigation_panel';
|
||||
|
||||
import { useBreakpoint } from '../hooks/useBreakpoint';
|
||||
@@ -85,9 +87,10 @@ export const ColumnsArea = forwardRef<
|
||||
HTMLDivElement,
|
||||
{
|
||||
singleColumn?: boolean;
|
||||
minimalShell?: boolean;
|
||||
children: React.ReactElement | React.ReactElement[];
|
||||
}
|
||||
>(({ children, singleColumn }, ref) => {
|
||||
>(({ children, minimalShell, singleColumn }, ref) => {
|
||||
const renderComposePanel = !useBreakpoint('full');
|
||||
const columns = useAppSelector((state) =>
|
||||
(state.settings as Record<{ columns: List<Record<Column>> }>).get(
|
||||
@@ -98,6 +101,24 @@ export const ColumnsArea = forwardRef<
|
||||
(state) => !state.modal.get('stack').isEmpty(),
|
||||
);
|
||||
|
||||
if (minimalShell) {
|
||||
return (
|
||||
<div className='columns-area__panels'>
|
||||
<div className='columns-area__panels__main'>
|
||||
<Header />
|
||||
|
||||
<div className='tabs-bar__wrapper'>
|
||||
<TabsBarPortal />
|
||||
</div>
|
||||
|
||||
<div className='columns-area columns-area--mobile'>{children}</div>
|
||||
|
||||
<Footer />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (singleColumn) {
|
||||
return (
|
||||
<div className='columns-area__panels'>
|
||||
@@ -112,6 +133,7 @@ export const ColumnsArea = forwardRef<
|
||||
<div className='tabs-bar__wrapper'>
|
||||
<TabsBarPortal />
|
||||
</div>
|
||||
|
||||
<div className='columns-area columns-area--mobile'>{children}</div>
|
||||
</main>
|
||||
|
||||
|
||||
@@ -11,7 +11,15 @@ import { me } from '@/mastodon/initial_state';
|
||||
|
||||
const makeGetStatusIds = (pending = false) => createSelector([
|
||||
(state, { type }) => state.getIn(['settings', type], ImmutableMap()),
|
||||
(state, { type }) => state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList()),
|
||||
(state, { type, maxItems }) => {
|
||||
const items = state.getIn(['timelines', type, pending ? 'pendingItems' : 'items'], ImmutableList());
|
||||
|
||||
if (maxItems) {
|
||||
return items.take(maxItems);
|
||||
}
|
||||
|
||||
return items;
|
||||
},
|
||||
(state) => state.get('statuses'),
|
||||
], (columnSettings, statusIds, statuses) => {
|
||||
return statusIds.filter(id => {
|
||||
@@ -41,8 +49,15 @@ const makeMapStateToProps = () => {
|
||||
const getStatusIds = makeGetStatusIds();
|
||||
const getPendingStatusIds = makeGetStatusIds(true);
|
||||
|
||||
const mapStateToProps = (state, { timelineId, initialLoadingState = true }) => ({
|
||||
statusIds: getStatusIds(state, { type: timelineId }),
|
||||
/**
|
||||
* @param {import('mastodon/store').RootState} state
|
||||
* @param {Object} props
|
||||
* @param {string} props.timelineId
|
||||
* @param {boolean} [props.initialLoadingState]
|
||||
* @param {number} [props.maxItems]
|
||||
*/
|
||||
const mapStateToProps = (state, { timelineId, initialLoadingState = true, maxItems }) => ({
|
||||
statusIds: getStatusIds(state, { type: timelineId, maxItems }),
|
||||
lastId: state.getIn(['timelines', timelineId, 'items'])?.last(),
|
||||
isLoading: state.getIn(['timelines', timelineId, 'isLoading'], initialLoadingState),
|
||||
isPartial: state.getIn(['timelines', timelineId, 'isPartial'], false),
|
||||
|
||||
@@ -29,7 +29,7 @@ import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../act
|
||||
import { clearHeight } from '../../actions/height_cache';
|
||||
import { fetchServer, fetchServerTranslationLanguages } from '../../actions/server';
|
||||
import { expandHomeTimeline } from '../../actions/timelines';
|
||||
import { initialState, me, owner, singleUserMode, trendsEnabled, landingPage, localLiveFeedAccess, disableHoverCards } from '../../initial_state';
|
||||
import { initialState, me, owner, singleUserMode, trendsEnabled, landingPage, localLiveFeedAccess, disableHoverCards, domain } from '../../initial_state';
|
||||
|
||||
import BundleColumnError from './components/bundle_column_error';
|
||||
import { NavigationBar } from './components/navigation_bar';
|
||||
@@ -88,6 +88,7 @@ import {
|
||||
import { ColumnsContextProvider } from './util/columns_context';
|
||||
import { focusColumn, getFocusedItemIndex, focusItemSibling, focusFirstItem } from './util/focusUtils';
|
||||
import { WrappedSwitch, WrappedRoute } from './util/react_router_helpers';
|
||||
import { CustomHomepage } from 'mastodon/features/custom_homepage';
|
||||
|
||||
// Dummy import, to make sure that <Status /> ends up in the application bundle.
|
||||
// Without this it ends up in ~8 very commonly used bundles.
|
||||
@@ -177,13 +178,15 @@ class SwitchingColumnsArea extends PureComponent {
|
||||
rootRedirect = '/explore';
|
||||
} else if (localLiveFeedAccess === 'public' && landingPage === 'local_feed') {
|
||||
rootRedirect = '/public/local';
|
||||
} else if (landingPage === 'overview') {
|
||||
rootRedirect = '/overview';
|
||||
} else {
|
||||
rootRedirect = '/about';
|
||||
}
|
||||
|
||||
return (
|
||||
<ColumnsContextProvider multiColumn={!singleColumn}>
|
||||
<ColumnsArea ref={this.setRef} singleColumn={singleColumn}>
|
||||
<ColumnsArea ref={this.setRef} singleColumn={singleColumn} domain={domain} minimalShell={!signedIn && landingPage === 'overview'}>
|
||||
<WrappedSwitch>
|
||||
<Redirect from='/' to={{pathname: rootRedirect, state: this.props.location.state}} exact />
|
||||
|
||||
@@ -262,6 +265,8 @@ class SwitchingColumnsArea extends PureComponent {
|
||||
<WrappedRoute path='/followed_tags' component={FollowedTags} content={children} />
|
||||
<WrappedRoute path='/mutes' component={Mutes} content={children} />
|
||||
<WrappedRoute path='/lists' component={Lists} content={children} />
|
||||
|
||||
<Route path='/overview' component={CustomHomepage} />
|
||||
<Route component={BundleColumnError} />
|
||||
</WrappedSwitch>
|
||||
</ColumnsArea>
|
||||
@@ -633,13 +638,18 @@ class UI extends PureComponent {
|
||||
cheat: this.handleDonate,
|
||||
};
|
||||
|
||||
const minimalShell = !this.props.identity.signedIn && landingPage === 'overview';
|
||||
|
||||
return (
|
||||
<Hotkeys global handlers={handlers}>
|
||||
<div className={classNames('ui', { 'is-composing': isComposing })} ref={this.setRef}>
|
||||
<SkipLinks
|
||||
multiColumn={layout === 'multi-column'}
|
||||
onFocusGettingStartedColumn={this.handleHotkeyGoToStart}
|
||||
/>
|
||||
{!minimalShell && (
|
||||
<SkipLinks
|
||||
multiColumn={layout === 'multi-column'}
|
||||
onFocusGettingStartedColumn={this.handleHotkeyGoToStart}
|
||||
/>
|
||||
)}
|
||||
|
||||
<SwitchingColumnsArea
|
||||
identity={this.props.identity}
|
||||
location={location}
|
||||
@@ -650,7 +660,7 @@ class UI extends PureComponent {
|
||||
{children}
|
||||
</SwitchingColumnsArea>
|
||||
|
||||
<NavigationBar />
|
||||
{!minimalShell && <NavigationBar />}
|
||||
{layout !== 'mobile' && <PictureInPicture />}
|
||||
<AlertsController />
|
||||
{!disableHoverCards && <HoverCardController />}
|
||||
|
||||
Reference in new issue
Block a user