Merge pull request #401 from ThibG/glitch-soc/features/unfold-thread
Port the “unfold thread” feature from Mastodon's UI to glitch-soc flavour
This commit is contained in:
commit
f4ed38272b
|
@ -23,12 +23,12 @@ export default class ColumnHeader extends React.PureComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
title: PropTypes.node.isRequired,
|
title: PropTypes.node,
|
||||||
icon: PropTypes.string.isRequired,
|
icon: PropTypes.string,
|
||||||
active: PropTypes.bool,
|
active: PropTypes.bool,
|
||||||
localSettings : ImmutablePropTypes.map,
|
localSettings : ImmutablePropTypes.map,
|
||||||
multiColumn: PropTypes.bool,
|
multiColumn: PropTypes.bool,
|
||||||
focusable: PropTypes.bool,
|
extraButton: PropTypes.node,
|
||||||
showBackButton: PropTypes.bool,
|
showBackButton: PropTypes.bool,
|
||||||
notifCleaning: PropTypes.bool, // true only for the notification column
|
notifCleaning: PropTypes.bool, // true only for the notification column
|
||||||
notifCleaningActive: PropTypes.bool,
|
notifCleaningActive: PropTypes.bool,
|
||||||
|
@ -41,10 +41,6 @@ export default class ColumnHeader extends React.PureComponent {
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
|
||||||
focusable: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
collapsed: true,
|
collapsed: true,
|
||||||
animating: false,
|
animating: false,
|
||||||
|
@ -91,7 +87,7 @@ export default class ColumnHeader extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { intl, icon, active, children, pinned, onPin, multiColumn, focusable, showBackButton, intl: { formatMessage }, notifCleaning, notifCleaningActive } = this.props;
|
const { intl, icon, active, children, pinned, onPin, multiColumn, extraButton, showBackButton, intl: { formatMessage }, notifCleaning, notifCleaningActive } = this.props;
|
||||||
const { collapsed, animating, animatingNCD } = this.state;
|
const { collapsed, animating, animatingNCD } = this.state;
|
||||||
|
|
||||||
let title = this.props.title;
|
let title = this.props.title;
|
||||||
|
@ -167,18 +163,26 @@ export default class ColumnHeader extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (children || multiColumn) {
|
if (children || multiColumn) {
|
||||||
collapseButton = <button className={collapsibleButtonClassName} aria-label={formatMessage(collapsed ? messages.show : messages.hide)} aria-pressed={collapsed ? 'false' : 'true'} onClick={this.handleToggleClick}><i className='fa fa-sliders' /></button>;
|
collapseButton = <button className={collapsibleButtonClassName} title={formatMessage(collapsed ? messages.show : messages.hide)} aria-label={formatMessage(collapsed ? messages.show : messages.hide)} aria-pressed={collapsed ? 'false' : 'true'} onClick={this.handleToggleClick}><i className='fa fa-sliders' /></button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasTitle = icon && title;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={wrapperClassName}>
|
<div className={wrapperClassName}>
|
||||||
<h1 tabIndex={focusable ? 0 : null} role='button' className={buttonClassName} aria-label={title} onClick={this.handleTitleClick}>
|
<h1 className={buttonClassName}>
|
||||||
<i className={`fa fa-fw fa-${icon} column-header__icon`} />
|
{hasTitle && (
|
||||||
<span className='column-header__title'>
|
<button onClick={this.handleTitleClick}>
|
||||||
{title}
|
<i className={`fa fa-fw fa-${icon} column-header__icon`} />
|
||||||
</span>
|
{title}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!hasTitle && backButton}
|
||||||
|
|
||||||
<div className='column-header__buttons'>
|
<div className='column-header__buttons'>
|
||||||
{backButton}
|
{hasTitle && backButton}
|
||||||
|
{extraButton}
|
||||||
{ notifCleaning ? (
|
{ notifCleaning ? (
|
||||||
<button
|
<button
|
||||||
aria-label={msgEnterNotifCleaning}
|
aria-label={msgEnterNotifCleaning}
|
||||||
|
|
|
@ -47,10 +47,12 @@ export default class Status extends ImmutablePureComponent {
|
||||||
onMoveDown: PropTypes.func,
|
onMoveDown: PropTypes.func,
|
||||||
getScrollPosition: PropTypes.func,
|
getScrollPosition: PropTypes.func,
|
||||||
updateScrollBottom: PropTypes.func,
|
updateScrollBottom: PropTypes.func,
|
||||||
|
expanded: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
isExpanded: null,
|
isExpanded: this.props.expanded,
|
||||||
|
isCollapsed: false,
|
||||||
autoCollapsed: false,
|
autoCollapsed: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +73,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
updateOnStates = [
|
updateOnStates = [
|
||||||
'isExpanded',
|
'isExpanded',
|
||||||
|
'isCollapsed',
|
||||||
]
|
]
|
||||||
|
|
||||||
// If our settings have changed to disable collapsed statuses, then we
|
// If our settings have changed to disable collapsed statuses, then we
|
||||||
|
@ -83,18 +86,21 @@ export default class Status extends ImmutablePureComponent {
|
||||||
// uncollapse our status accordingly.
|
// uncollapse our status accordingly.
|
||||||
componentWillReceiveProps (nextProps) {
|
componentWillReceiveProps (nextProps) {
|
||||||
if (!nextProps.settings.getIn(['collapsed', 'enabled'])) {
|
if (!nextProps.settings.getIn(['collapsed', 'enabled'])) {
|
||||||
if (this.state.isExpanded === false) {
|
if (this.state.isCollapsed) {
|
||||||
this.setExpansion(null);
|
this.setCollapsed(false);
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
nextProps.collapse !== this.props.collapse &&
|
nextProps.collapse !== this.props.collapse &&
|
||||||
nextProps.collapse !== undefined
|
nextProps.collapse !== undefined
|
||||||
) this.setExpansion(nextProps.collapse ? false : null);
|
) this.setCollapsed(nextProps.collapse);
|
||||||
|
if (nextProps.expanded !== this.props.expanded &&
|
||||||
|
nextProps.expanded !== undefined
|
||||||
|
) this.setExpansion(nextProps.expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When mounting, we just check to see if our status should be collapsed,
|
// When mounting, we just check to see if our status should be collapsed,
|
||||||
// and collapse it if so. We don't need to worry about whether collapsing
|
// and collapse it if so. We don't need to worry about whether collapsing
|
||||||
// is enabled here, because `setExpansion()` already takes that into
|
// is enabled here, because `setCollapsed()` already takes that into
|
||||||
// account.
|
// account.
|
||||||
|
|
||||||
// The cases where a status should be collapsed are:
|
// The cases where a status should be collapsed are:
|
||||||
|
@ -138,7 +144,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}()) {
|
}()) {
|
||||||
this.setExpansion(false);
|
this.setCollapsed(true);
|
||||||
// Hack to fix timeline jumps on second rendering when auto-collapsing
|
// Hack to fix timeline jumps on second rendering when auto-collapsing
|
||||||
this.setState({ autoCollapsed: true });
|
this.setState({ autoCollapsed: true });
|
||||||
}
|
}
|
||||||
|
@ -164,23 +170,26 @@ export default class Status extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// `setExpansion()` sets the value of `isExpanded` in our state. It takes
|
// `setCollapsed()` sets the value of `isCollapsed` in our state, that is,
|
||||||
// one argument, `value`, which gives the desired value for `isExpanded`.
|
// whether the toot is collapsed or not.
|
||||||
// The default for this argument is `null`.
|
|
||||||
|
|
||||||
// `setExpansion()` automatically checks for us whether toot collapsing
|
// `setCollapsed()` automatically checks for us whether toot collapsing
|
||||||
// is enabled, so we don't have to.
|
// is enabled, so we don't have to.
|
||||||
|
setCollapsed = (value) => {
|
||||||
|
if (this.props.settings.getIn(['collapsed', 'enabled'])) {
|
||||||
|
this.setState({ isCollapsed: value });
|
||||||
|
if (value) {
|
||||||
|
this.setExpansion(false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.setState({ isCollapsed: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setExpansion = (value) => {
|
setExpansion = (value) => {
|
||||||
switch (true) {
|
this.setState({ isExpanded: value });
|
||||||
case value === undefined || value === null:
|
if (value) {
|
||||||
this.setState({ isExpanded: null });
|
this.setCollapsed(false);
|
||||||
break;
|
|
||||||
case !value && this.props.settings.getIn(['collapsed', 'enabled']):
|
|
||||||
this.setState({ isExpanded: false });
|
|
||||||
break;
|
|
||||||
case !!value:
|
|
||||||
this.setState({ isExpanded: true });
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +201,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
parseClick = (e, destination) => {
|
parseClick = (e, destination) => {
|
||||||
const { router } = this.context;
|
const { router } = this.context;
|
||||||
const { status } = this.props;
|
const { status } = this.props;
|
||||||
const { isExpanded } = this.state;
|
const { isCollapsed } = this.state;
|
||||||
if (!router) return;
|
if (!router) return;
|
||||||
if (destination === undefined) {
|
if (destination === undefined) {
|
||||||
destination = `/statuses/${
|
destination = `/statuses/${
|
||||||
|
@ -200,9 +209,9 @@ export default class Status extends ImmutablePureComponent {
|
||||||
}`;
|
}`;
|
||||||
}
|
}
|
||||||
if (e.button === 0) {
|
if (e.button === 0) {
|
||||||
if (isExpanded === false) this.setExpansion(null);
|
if (isCollapsed) this.setCollapsed(false);
|
||||||
else if (e.shiftKey) {
|
else if (e.shiftKey) {
|
||||||
this.setExpansion(false);
|
this.setCollapsed(true);
|
||||||
document.getSelection().removeAllRanges();
|
document.getSelection().removeAllRanges();
|
||||||
} else router.history.push(destination);
|
} else router.history.push(destination);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -219,7 +228,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
handleExpandedToggle = () => {
|
handleExpandedToggle = () => {
|
||||||
if (this.props.status.get('spoiler_text')) {
|
if (this.props.status.get('spoiler_text')) {
|
||||||
this.setExpansion(this.state.isExpanded ? null : true);
|
this.setExpansion(!this.state.isExpanded);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -278,6 +287,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
handleRef,
|
handleRef,
|
||||||
parseClick,
|
parseClick,
|
||||||
setExpansion,
|
setExpansion,
|
||||||
|
setCollapsed,
|
||||||
} = this;
|
} = this;
|
||||||
const { router } = this.context;
|
const { router } = this.context;
|
||||||
const {
|
const {
|
||||||
|
@ -295,7 +305,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
featured,
|
featured,
|
||||||
...other
|
...other
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { isExpanded } = this.state;
|
const { isExpanded, isCollapsed } = this.state;
|
||||||
let background = null;
|
let background = null;
|
||||||
let attachments = null;
|
let attachments = null;
|
||||||
let media = null;
|
let media = null;
|
||||||
|
@ -414,8 +424,8 @@ export default class Status extends ImmutablePureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
const computedClass = classNames('status', `status-${status.get('visibility')}`, {
|
const computedClass = classNames('status', `status-${status.get('visibility')}`, {
|
||||||
collapsed: isExpanded === false,
|
collapsed: isCollapsed,
|
||||||
'has-background': isExpanded === false && background,
|
'has-background': isCollapsed && background,
|
||||||
muted,
|
muted,
|
||||||
}, 'focusable');
|
}, 'focusable');
|
||||||
|
|
||||||
|
@ -423,7 +433,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
<HotKeys handlers={handlers}>
|
<HotKeys handlers={handlers}>
|
||||||
<div
|
<div
|
||||||
className={computedClass}
|
className={computedClass}
|
||||||
style={isExpanded === false && background ? { backgroundImage: `url(${background})` } : null}
|
style={isCollapsed && background ? { backgroundImage: `url(${background})` } : null}
|
||||||
{...selectorAttribs}
|
{...selectorAttribs}
|
||||||
ref={handleRef}
|
ref={handleRef}
|
||||||
tabIndex='0'
|
tabIndex='0'
|
||||||
|
@ -439,11 +449,11 @@ export default class Status extends ImmutablePureComponent {
|
||||||
notificationId={this.props.notificationId}
|
notificationId={this.props.notificationId}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{!muted || isExpanded !== false ? (
|
{!muted || !isCollapsed ? (
|
||||||
<StatusHeader
|
<StatusHeader
|
||||||
status={status}
|
status={status}
|
||||||
friend={account}
|
friend={account}
|
||||||
collapsed={isExpanded === false}
|
collapsed={isCollapsed}
|
||||||
parseClick={parseClick}
|
parseClick={parseClick}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
|
@ -452,8 +462,8 @@ export default class Status extends ImmutablePureComponent {
|
||||||
status={status}
|
status={status}
|
||||||
mediaIcon={mediaIcon}
|
mediaIcon={mediaIcon}
|
||||||
collapsible={settings.getIn(['collapsed', 'enabled'])}
|
collapsible={settings.getIn(['collapsed', 'enabled'])}
|
||||||
collapsed={isExpanded === false}
|
collapsed={isCollapsed}
|
||||||
setExpansion={setExpansion}
|
setCollapsed={setCollapsed}
|
||||||
/>
|
/>
|
||||||
</header>
|
</header>
|
||||||
<StatusContent
|
<StatusContent
|
||||||
|
@ -461,11 +471,11 @@ export default class Status extends ImmutablePureComponent {
|
||||||
media={media}
|
media={media}
|
||||||
mediaIcon={mediaIcon}
|
mediaIcon={mediaIcon}
|
||||||
expanded={isExpanded}
|
expanded={isExpanded}
|
||||||
setExpansion={setExpansion}
|
onExpandedToggle={this.handleExpandedToggle}
|
||||||
parseClick={parseClick}
|
parseClick={parseClick}
|
||||||
disabled={!router}
|
disabled={!router}
|
||||||
/>
|
/>
|
||||||
{isExpanded !== false || !muted ? (
|
{!isCollapsed || !muted ? (
|
||||||
<StatusActionBar
|
<StatusActionBar
|
||||||
{...other}
|
{...other}
|
||||||
status={status}
|
status={status}
|
||||||
|
|
|
@ -11,7 +11,8 @@ export default class StatusContent extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
status: ImmutablePropTypes.map.isRequired,
|
status: ImmutablePropTypes.map.isRequired,
|
||||||
expanded: PropTypes.bool,
|
expanded: PropTypes.bool,
|
||||||
setExpansion: PropTypes.func,
|
collapsed: PropTypes.bool,
|
||||||
|
onExpandedToggle: PropTypes.func,
|
||||||
media: PropTypes.element,
|
media: PropTypes.element,
|
||||||
mediaIcon: PropTypes.string,
|
mediaIcon: PropTypes.string,
|
||||||
parseClick: PropTypes.func,
|
parseClick: PropTypes.func,
|
||||||
|
@ -64,7 +65,7 @@ export default class StatusContent extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
onLinkClick = (e) => {
|
onLinkClick = (e) => {
|
||||||
if (this.props.expanded === false) {
|
if (this.props.collapsed) {
|
||||||
if (this.props.parseClick) this.props.parseClick(e);
|
if (this.props.parseClick) this.props.parseClick(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,8 +112,8 @@ export default class StatusContent extends React.PureComponent {
|
||||||
handleSpoilerClick = (e) => {
|
handleSpoilerClick = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (this.props.setExpansion) {
|
if (this.props.onExpandedToggle) {
|
||||||
this.props.setExpansion(this.props.expanded ? null : true);
|
this.props.onExpandedToggle();
|
||||||
} else {
|
} else {
|
||||||
this.setState({ hidden: !this.state.hidden });
|
this.setState({ hidden: !this.state.hidden });
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ export default class StatusContent extends React.PureComponent {
|
||||||
disabled,
|
disabled,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const hidden = this.props.setExpansion ? !this.props.expanded : this.state.hidden;
|
const hidden = this.props.onExpandedToggle ? !this.props.expanded : this.state.hidden;
|
||||||
|
|
||||||
const content = { __html: status.get('contentHtml') };
|
const content = { __html: status.get('contentHtml') };
|
||||||
const spoilerContent = { __html: status.get('spoilerHtml') };
|
const spoilerContent = { __html: status.get('spoilerHtml') };
|
||||||
|
|
|
@ -22,15 +22,15 @@ export default class StatusIcons extends React.PureComponent {
|
||||||
mediaIcon: PropTypes.string,
|
mediaIcon: PropTypes.string,
|
||||||
collapsible: PropTypes.bool,
|
collapsible: PropTypes.bool,
|
||||||
collapsed: PropTypes.bool,
|
collapsed: PropTypes.bool,
|
||||||
setExpansion: PropTypes.func.isRequired,
|
setCollapsed: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles clicks on collapsed button
|
// Handles clicks on collapsed button
|
||||||
handleCollapsedClick = (e) => {
|
handleCollapsedClick = (e) => {
|
||||||
const { collapsed, setExpansion } = this.props;
|
const { collapsed, setCollapsed } = this.props;
|
||||||
if (e.button === 0) {
|
if (e.button === 0) {
|
||||||
setExpansion(collapsed ? null : false);
|
setCollapsed(!collapsed);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ export default class DetailedStatus extends ImmutablePureComponent {
|
||||||
settings: ImmutablePropTypes.map.isRequired,
|
settings: ImmutablePropTypes.map.isRequired,
|
||||||
onOpenMedia: PropTypes.func.isRequired,
|
onOpenMedia: PropTypes.func.isRequired,
|
||||||
onOpenVideo: PropTypes.func.isRequired,
|
onOpenVideo: PropTypes.func.isRequired,
|
||||||
|
onToggleHidden: PropTypes.func.isRequired,
|
||||||
|
expanded: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleAccountClick = (e) => {
|
handleAccountClick = (e) => {
|
||||||
|
@ -41,7 +43,7 @@ export default class DetailedStatus extends ImmutablePureComponent {
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status;
|
const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status;
|
||||||
const { expanded, setExpansion, settings } = this.props;
|
const { expanded, onToggleHidden, settings } = this.props;
|
||||||
|
|
||||||
let media = '';
|
let media = '';
|
||||||
let mediaIcon = null;
|
let mediaIcon = null;
|
||||||
|
@ -114,7 +116,8 @@ export default class DetailedStatus extends ImmutablePureComponent {
|
||||||
media={media}
|
media={media}
|
||||||
mediaIcon={mediaIcon}
|
mediaIcon={mediaIcon}
|
||||||
expanded={expanded}
|
expanded={expanded}
|
||||||
setExpansion={setExpansion}
|
collapsed={false}
|
||||||
|
onExpandedToggle={onToggleHidden}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div className='detailed-status__meta'>
|
<div className='detailed-status__meta'>
|
||||||
|
|
|
@ -29,6 +29,7 @@ import { initReport } from 'flavours/glitch/actions/reports';
|
||||||
import { makeGetStatus } from 'flavours/glitch/selectors';
|
import { makeGetStatus } from 'flavours/glitch/selectors';
|
||||||
import { ScrollContainer } from 'react-router-scroll-4';
|
import { ScrollContainer } from 'react-router-scroll-4';
|
||||||
import ColumnBackButton from 'flavours/glitch/components/column_back_button';
|
import ColumnBackButton from 'flavours/glitch/components/column_back_button';
|
||||||
|
import ColumnHeader from '../../components/column_header';
|
||||||
import StatusContainer from 'flavours/glitch/containers/status_container';
|
import StatusContainer from 'flavours/glitch/containers/status_container';
|
||||||
import { openModal } from 'flavours/glitch/actions/modal';
|
import { openModal } from 'flavours/glitch/actions/modal';
|
||||||
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||||||
|
@ -41,6 +42,8 @@ const messages = defineMessages({
|
||||||
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||||
deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' },
|
deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' },
|
||||||
blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
|
blockConfirm: { id: 'confirmations.block.confirm', defaultMessage: 'Block' },
|
||||||
|
revealAll: { id: 'status.show_more_all', defaultMessage: 'Show more for all' },
|
||||||
|
hideAll: { id: 'status.show_less_all', defaultMessage: 'Show less for all' },
|
||||||
});
|
});
|
||||||
|
|
||||||
const makeMapStateToProps = () => {
|
const makeMapStateToProps = () => {
|
||||||
|
@ -76,7 +79,8 @@ export default class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
isExpanded: null,
|
isExpanded: false,
|
||||||
|
threadExpanded: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillMount () {
|
componentWillMount () {
|
||||||
|
@ -96,7 +100,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
handleExpandedToggle = () => {
|
handleExpandedToggle = () => {
|
||||||
if (this.props.status.get('spoiler_text')) {
|
if (this.props.status.get('spoiler_text')) {
|
||||||
this.setExpansion(this.state.isExpanded ? null : true);
|
this.setExpansion(!this.state.isExpanded);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -190,6 +194,11 @@ export default class Status extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleToggleAll = () => {
|
||||||
|
const { isExpanded } = this.state;
|
||||||
|
this.setState({ isExpanded: !isExpanded, threadExpanded: !isExpanded });
|
||||||
|
}
|
||||||
|
|
||||||
handleBlockClick = (account) => {
|
handleBlockClick = (account) => {
|
||||||
const { dispatch, intl } = this.props;
|
const { dispatch, intl } = this.props;
|
||||||
|
|
||||||
|
@ -285,6 +294,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
<StatusContainer
|
<StatusContainer
|
||||||
key={id}
|
key={id}
|
||||||
id={id}
|
id={id}
|
||||||
|
expanded={this.state.threadExpanded}
|
||||||
onMoveUp={this.handleMoveUp}
|
onMoveUp={this.handleMoveUp}
|
||||||
onMoveDown={this.handleMoveDown}
|
onMoveDown={this.handleMoveDown}
|
||||||
/>
|
/>
|
||||||
|
@ -292,7 +302,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
setExpansion = value => {
|
setExpansion = value => {
|
||||||
this.setState({ isExpanded: value ? true : null });
|
this.setState({ isExpanded: value });
|
||||||
}
|
}
|
||||||
|
|
||||||
setRef = c => {
|
setRef = c => {
|
||||||
|
@ -327,7 +337,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
render () {
|
render () {
|
||||||
let ancestors, descendants;
|
let ancestors, descendants;
|
||||||
const { setExpansion } = this;
|
const { setExpansion } = this;
|
||||||
const { status, settings, ancestorsIds, descendantsIds } = this.props;
|
const { status, settings, ancestorsIds, descendantsIds, intl } = this.props;
|
||||||
const { fullscreen, isExpanded } = this.state;
|
const { fullscreen, isExpanded } = this.state;
|
||||||
|
|
||||||
if (status === null) {
|
if (status === null) {
|
||||||
|
@ -360,7 +370,12 @@ export default class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column>
|
<Column>
|
||||||
<ColumnBackButton />
|
<ColumnHeader
|
||||||
|
showBackButton
|
||||||
|
extraButton={(
|
||||||
|
<button className='column-header__button' title={intl.formatMessage(!isExpanded ? messages.revealAll : messages.hideAll)} aria-label={intl.formatMessage(!isExpanded ? messages.revealAll : messages.hideAll)} onClick={this.handleToggleAll} aria-pressed={!isExpanded ? 'false' : 'true'}><i className={`fa fa-${!isExpanded ? 'eye-slash' : 'eye'}`} /></button>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
<ScrollContainer scrollKey='thread'>
|
<ScrollContainer scrollKey='thread'>
|
||||||
<div className={classNames('scrollable', 'detailed-status__wrapper', { fullscreen })} ref={this.setRef}>
|
<div className={classNames('scrollable', 'detailed-status__wrapper', { fullscreen })} ref={this.setRef}>
|
||||||
|
@ -374,7 +389,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
onOpenVideo={this.handleOpenVideo}
|
onOpenVideo={this.handleOpenVideo}
|
||||||
onOpenMedia={this.handleOpenMedia}
|
onOpenMedia={this.handleOpenMedia}
|
||||||
expanded={isExpanded}
|
expanded={isExpanded}
|
||||||
setExpansion={setExpansion}
|
onToggleHidden={this.handleExpandedToggle}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ActionBar
|
<ActionBar
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
export default class ColumnHeader extends React.PureComponent {
|
export default class ColumnHeader extends React.PureComponent {
|
||||||
|
|
||||||
|
@ -16,19 +17,20 @@ export default class ColumnHeader extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { type, active, columnHeaderId } = this.props;
|
const { icon, type, active, columnHeaderId } = this.props;
|
||||||
|
let iconElement = '';
|
||||||
|
|
||||||
let icon = '';
|
if (icon) {
|
||||||
|
iconElement = <i className={`fa fa-fw fa-${icon} column-header__icon`} />;
|
||||||
if (this.props.icon) {
|
|
||||||
icon = <i className={`fa fa-fw fa-${this.props.icon} column-header__icon`} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div role='heading' tabIndex='0' className={`column-header ${active ? 'active' : ''}`} onClick={this.handleClick} id={columnHeaderId || null}>
|
<h1 className={classNames('column-header', { active })} id={columnHeaderId || null}>
|
||||||
{icon}
|
<button onClick={this.handleClick}>
|
||||||
{type}
|
{iconElement}
|
||||||
</div>
|
{type}
|
||||||
|
</button>
|
||||||
|
</h1>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,16 +62,20 @@ const normalizeStatus = (state, status) => {
|
||||||
normalStatus.reblog = status.reblog.id;
|
normalStatus.reblog = status.reblog.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
// Only calculate these values when status first encountered
|
||||||
|
// Otherwise keep the ones already in the reducer
|
||||||
|
if (!state.has(status.id)) {
|
||||||
|
const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||||
|
|
||||||
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
|
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
|
||||||
obj[`:${emoji.shortcode}:`] = emoji;
|
obj[`:${emoji.shortcode}:`] = emoji;
|
||||||
return obj;
|
return obj;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
|
normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
|
||||||
normalStatus.contentHtml = emojify(normalStatus.content, emojiMap);
|
normalStatus.contentHtml = emojify(normalStatus.content, emojiMap);
|
||||||
normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(normalStatus.spoiler_text || ''), emojiMap);
|
normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(normalStatus.spoiler_text || ''), emojiMap);
|
||||||
|
}
|
||||||
|
|
||||||
return state.update(status.id, ImmutableMap(), map => map.mergeDeep(fromJS(normalStatus)));
|
return state.update(status.id, ImmutableMap(), map => map.mergeDeep(fromJS(normalStatus)));
|
||||||
};
|
};
|
||||||
|
|
|
@ -243,7 +243,6 @@
|
||||||
.column-header {
|
.column-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
padding: 15px;
|
|
||||||
background: lighten($ui-base-color, 4%);
|
background: lighten($ui-base-color, 4%);
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -255,7 +254,7 @@
|
||||||
& > button {
|
& > button {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border: none;
|
border: none;
|
||||||
padding: 15px 0 15px 15px;
|
padding: 15px;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
font: inherit;
|
font: inherit;
|
||||||
|
@ -266,6 +265,10 @@
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& > .column-header__back-button {
|
||||||
|
color: $ui-highlight-color;
|
||||||
|
}
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
box-shadow: 0 1px 0 rgba($ui-highlight-color, 0.3);
|
box-shadow: 0 1px 0 rgba($ui-highlight-color, 0.3);
|
||||||
|
|
||||||
|
@ -303,7 +306,6 @@
|
||||||
.column-header__buttons {
|
.column-header__buttons {
|
||||||
height: 48px;
|
height: 48px;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: -15px;
|
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue