Use ScrollableList in threads
This commit is contained in:
parent
8becc4de2a
commit
a616ed215b
2 changed files with 80 additions and 86 deletions
|
@ -17,7 +17,7 @@ import {
|
||||||
} from 'soapbox/actions/moderation';
|
} from 'soapbox/actions/moderation';
|
||||||
import { getSettings } from 'soapbox/actions/settings';
|
import { getSettings } from 'soapbox/actions/settings';
|
||||||
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
|
||||||
import PullToRefresh from 'soapbox/components/pull-to-refresh';
|
import ScrollableList from 'soapbox/components/scrollable_list';
|
||||||
import SubNavigation from 'soapbox/components/sub_navigation';
|
import SubNavigation from 'soapbox/components/sub_navigation';
|
||||||
import { Column } from 'soapbox/components/ui';
|
import { Column } from 'soapbox/components/ui';
|
||||||
import PlaceholderStatus from 'soapbox/features/placeholder/components/placeholder_status';
|
import PlaceholderStatus from 'soapbox/features/placeholder/components/placeholder_status';
|
||||||
|
@ -642,9 +642,11 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let ancestors, descendants;
|
|
||||||
const { status, ancestorsIds, descendantsIds, intl } = this.props;
|
const { status, ancestorsIds, descendantsIds, intl } = this.props;
|
||||||
|
|
||||||
|
const hasAncestors = ancestorsIds && ancestorsIds.size > 0;
|
||||||
|
const hasDescendants = descendantsIds && descendantsIds.size > 0;
|
||||||
|
|
||||||
if (!status && this.state.isLoaded) {
|
if (!status && this.state.isLoaded) {
|
||||||
// TODO: handle errors other than 404 with `this.state.error?.response?.status`
|
// TODO: handle errors other than 404 with `this.state.error?.response?.status`
|
||||||
return (
|
return (
|
||||||
|
@ -656,14 +658,6 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ancestorsIds && ancestorsIds.size > 0) {
|
|
||||||
ancestors = this.renderChildren(ancestorsIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descendantsIds && descendantsIds.size > 0) {
|
|
||||||
descendants = this.renderChildren(descendantsIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
type HotkeyHandlers = { [key: string]: (keyEvent?: KeyboardEvent) => void };
|
type HotkeyHandlers = { [key: string]: (keyEvent?: KeyboardEvent) => void };
|
||||||
|
|
||||||
const handlers: HotkeyHandlers = {
|
const handlers: HotkeyHandlers = {
|
||||||
|
@ -683,19 +677,8 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
const username = String(status.getIn(['account', 'acct']));
|
const username = String(status.getIn(['account', 'acct']));
|
||||||
const titleMessage = status.visibility === 'direct' ? messages.titleDirect : messages.title;
|
const titleMessage = status.visibility === 'direct' ? messages.titleDirect : messages.title;
|
||||||
|
|
||||||
return (
|
const focusedStatus = (
|
||||||
<Column label={intl.formatMessage(titleMessage, { username })} transparent>
|
<div className={classNames('thread__detailed-status', { 'pb-4': hasDescendants })} key={status.id}>
|
||||||
<div className='px-4 pt-4 sm:p-0'>
|
|
||||||
<SubNavigation message={intl.formatMessage(titleMessage, { username })} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ref={this.setRef} className='thread'>
|
|
||||||
<PullToRefresh onRefresh={this.handleRefresh}>
|
|
||||||
{ancestors && (
|
|
||||||
<div className='thread__ancestors space-y-4 mb-4'>{ancestors}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className='thread__status thread__status--focused'>
|
|
||||||
<HotKeys handlers={handlers}>
|
<HotKeys handlers={handlers}>
|
||||||
<div
|
<div
|
||||||
ref={this.setStatusRef}
|
ref={this.setStatusRef}
|
||||||
|
@ -745,15 +728,35 @@ class Status extends ImmutablePureComponent<IStatus, IStatusState> {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</HotKeys>
|
</HotKeys>
|
||||||
|
|
||||||
|
{hasDescendants && (
|
||||||
|
<hr className='mt-2 dark:border-slate-600' />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const children: JSX.Element[] = [];
|
||||||
|
|
||||||
|
if (hasAncestors) {
|
||||||
|
children.push(...this.renderChildren(ancestorsIds).toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
children.push(focusedStatus);
|
||||||
|
|
||||||
|
if (hasDescendants) {
|
||||||
|
children.push(...this.renderChildren(descendantsIds).toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Column label={intl.formatMessage(titleMessage, { username })} transparent>
|
||||||
|
<div className='px-4 pt-4 sm:p-0'>
|
||||||
|
<SubNavigation message={intl.formatMessage(titleMessage, { username })} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{descendants && (
|
<div ref={this.setRef} className='thread'>
|
||||||
<>
|
<ScrollableList onRefresh={this.handleRefresh}>
|
||||||
<hr className='mt-2 dark:border-slate-600' />
|
{children}
|
||||||
<div className='thread__descendants space-y-4'>{descendants}</div>
|
</ScrollableList>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</PullToRefresh>
|
|
||||||
</div>
|
</div>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|
|
@ -170,7 +170,7 @@
|
||||||
@apply sm:bg-white sm:dark:bg-slate-800 p-4 sm:shadow-xl sm:p-6 sm:rounded-xl;
|
@apply sm:bg-white sm:dark:bg-slate-800 p-4 sm:shadow-xl sm:p-6 sm:rounded-xl;
|
||||||
|
|
||||||
&__status {
|
&__status {
|
||||||
@apply relative;
|
@apply relative pb-4;
|
||||||
|
|
||||||
.status__wrapper {
|
.status__wrapper {
|
||||||
@apply shadow-none p-0;
|
@apply shadow-none p-0;
|
||||||
|
@ -182,16 +182,7 @@
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
&__descendants {
|
.status__content-wrapper {
|
||||||
@apply pt-4;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__descendants .thread__status {
|
|
||||||
// @apply py-4;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__descendants .status__content-wrapper,
|
|
||||||
&__ancestors .status__content-wrapper {
|
|
||||||
padding-left: calc(42px + 12px);
|
padding-left: calc(42px + 12px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +216,7 @@
|
||||||
|
|
||||||
&--bottom {
|
&--bottom {
|
||||||
@apply block;
|
@apply block;
|
||||||
height: calc(100% - 42px - 8px);
|
height: calc(100% - 42px - 8px - 1rem);
|
||||||
top: calc(12px + 42px);
|
top: calc(12px + 42px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue