Skip to content

Commit 140f746

Browse files
kedamaDQhiyuki2578
authored andcommitted
Back to the getting-started when pins the timeline. (mastodon#9561)
1 parent ed74d3d commit 140f746

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

app/javascript/mastodon/components/column_header.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ class ColumnHeader extends React.PureComponent {
3737
animating: false,
3838
};
3939

40+
historyBack = () => {
41+
if (window.history && window.history.length === 1) {
42+
this.context.router.history.push('/');
43+
} else {
44+
this.context.router.history.goBack();
45+
}
46+
}
47+
4048
handleToggleClick = (e) => {
4149
e.stopPropagation();
4250
this.setState({ collapsed: !this.state.collapsed, animating: true });
@@ -55,16 +63,22 @@ class ColumnHeader extends React.PureComponent {
5563
}
5664

5765
handleBackClick = () => {
58-
if (window.history && window.history.length === 1) this.context.router.history.push('/');
59-
else this.context.router.history.goBack();
66+
this.historyBack();
6067
}
6168

6269
handleTransitionEnd = () => {
6370
this.setState({ animating: false });
6471
}
6572

73+
handlePin = () => {
74+
if (!this.props.pinned) {
75+
this.historyBack();
76+
}
77+
this.props.onPin();
78+
}
79+
6680
render () {
67-
const { title, icon, active, children, pinned, onPin, multiColumn, extraButton, showBackButton, intl: { formatMessage } } = this.props;
81+
const { title, icon, active, children, pinned, multiColumn, extraButton, showBackButton, intl: { formatMessage } } = this.props;
6882
const { collapsed, animating } = this.state;
6983

7084
const wrapperClassName = classNames('column-header__wrapper', {
@@ -95,7 +109,7 @@ class ColumnHeader extends React.PureComponent {
95109
}
96110

97111
if (multiColumn && pinned) {
98-
pinButton = <button key='pin-button' className='text-btn column-header__setting-btn' onClick={onPin}><i className='fa fa fa-times' /> <FormattedMessage id='column_header.unpin' defaultMessage='Unpin' /></button>;
112+
pinButton = <button key='pin-button' className='text-btn column-header__setting-btn' onClick={this.handlePin}><i className='fa fa fa-times' /> <FormattedMessage id='column_header.unpin' defaultMessage='Unpin' /></button>;
99113

100114
moveButtons = (
101115
<div key='move-buttons' className='column-header__setting-arrows'>
@@ -104,7 +118,7 @@ class ColumnHeader extends React.PureComponent {
104118
</div>
105119
);
106120
} else if (multiColumn) {
107-
pinButton = <button key='pin-button' className='text-btn column-header__setting-btn' onClick={onPin}><i className='fa fa fa-plus' /> <FormattedMessage id='column_header.pin' defaultMessage='Pin' /></button>;
121+
pinButton = <button key='pin-button' className='text-btn column-header__setting-btn' onClick={this.handlePin}><i className='fa fa fa-plus' /> <FormattedMessage id='column_header.pin' defaultMessage='Pin' /></button>;
108122
}
109123

110124
if (!pinned && (multiColumn || showBackButton)) {

0 commit comments

Comments
 (0)