Browse Source

Shift+click on column Back button to return to last pinable column

closed-social-glitch-2
Thibaut Girka 5 years ago
committed by ThibG
parent
commit
e3c1472040
11 changed files with 61 additions and 20 deletions
  1. +7
    -2
      app/javascript/flavours/glitch/components/column_back_button.js
  2. +7
    -2
      app/javascript/flavours/glitch/components/column_back_button_slim.js
  3. +9
    -4
      app/javascript/flavours/glitch/components/column_header.js
  4. +3
    -1
      app/javascript/flavours/glitch/components/permalink.js
  5. +14
    -4
      app/javascript/flavours/glitch/components/status.js
  6. +3
    -1
      app/javascript/flavours/glitch/components/status_action_bar.js
  7. +3
    -1
      app/javascript/flavours/glitch/features/account_timeline/components/moved_note.js
  8. +6
    -2
      app/javascript/flavours/glitch/features/status/components/detailed_status.js
  9. +3
    -1
      app/javascript/flavours/glitch/features/status/index.js
  10. +3
    -1
      app/javascript/flavours/glitch/features/ui/components/boost_modal.js
  11. +3
    -1
      app/javascript/flavours/glitch/features/ui/components/favourite_modal.js

+ 7
- 2
app/javascript/flavours/glitch/components/column_back_button.js View File

@ -8,10 +8,15 @@ export default class ColumnBackButton extends React.PureComponent {
router: PropTypes.object, router: PropTypes.object,
}; };
handleClick = () => {
handleClick = (event) => {
// if history is exhausted, or we would leave mastodon, just go to root. // if history is exhausted, or we would leave mastodon, just go to root.
if (window.history.state) { if (window.history.state) {
this.context.router.history.goBack();
const state = this.context.router.history.location.state;
if (event.shiftKey && state && state.mastodonBackSteps) {
this.context.router.history.go(-state.mastodonBackSteps);
} else {
this.context.router.history.goBack();
}
} else { } else {
this.context.router.history.push('/'); this.context.router.history.push('/');
} }

+ 7
- 2
app/javascript/flavours/glitch/components/column_back_button_slim.js View File

@ -8,10 +8,15 @@ export default class ColumnBackButtonSlim extends React.PureComponent {
router: PropTypes.object, router: PropTypes.object,
}; };
handleClick = () => {
handleClick = (event) => {
// if history is exhausted, or we would leave mastodon, just go to root. // if history is exhausted, or we would leave mastodon, just go to root.
if (window.history.state) { if (window.history.state) {
this.context.router.history.goBack();
const state = this.context.router.history.location.state;
if (event.shiftKey && state && state.mastodonBackSteps) {
this.context.router.history.go(-state.mastodonBackSteps);
} else {
this.context.router.history.goBack();
}
} else { } else {
this.context.router.history.push('/'); this.context.router.history.push('/');
} }

+ 9
- 4
app/javascript/flavours/glitch/components/column_header.js View File

@ -47,10 +47,15 @@ export default class ColumnHeader extends React.PureComponent {
animatingNCD: false, animatingNCD: false,
}; };
historyBack = () => {
historyBack = (skip) => {
// if history is exhausted, or we would leave mastodon, just go to root. // if history is exhausted, or we would leave mastodon, just go to root.
if (window.history.state) { if (window.history.state) {
this.context.router.history.goBack();
const state = this.context.router.history.location.state;
if (skip && state && state.mastodonBackSteps) {
this.context.router.history.go(-state.mastodonBackSteps);
} else {
this.context.router.history.goBack();
}
} else { } else {
this.context.router.history.push('/'); this.context.router.history.push('/');
} }
@ -73,8 +78,8 @@ export default class ColumnHeader extends React.PureComponent {
this.props.onMove(1); this.props.onMove(1);
} }
handleBackClick = () => {
this.historyBack();
handleBackClick = (event) => {
this.historyBack(event.shiftKey);
} }
handleTransitionEnd = () => { handleTransitionEnd = () => {

+ 3
- 1
app/javascript/flavours/glitch/components/permalink.js View File

@ -24,7 +24,9 @@ export default class Permalink extends React.PureComponent {
if (this.context.router) { if (this.context.router) {
e.preventDefault(); e.preventDefault();
this.context.router.history.push(this.props.to);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(this.props.to, state);
} }
} }
} }

+ 14
- 4
app/javascript/flavours/glitch/components/status.js View File

@ -295,7 +295,11 @@ export default class Status extends ImmutablePureComponent {
else if (e.shiftKey) { else if (e.shiftKey) {
this.setCollapsed(true); this.setCollapsed(true);
document.getSelection().removeAllRanges(); document.getSelection().removeAllRanges();
} else router.history.push(destination);
} else {
let state = {...router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
router.history.push(destination, state);
}
e.preventDefault(); e.preventDefault();
} }
} }
@ -304,7 +308,9 @@ export default class Status extends ImmutablePureComponent {
if (this.context.router && e.button === 0) { if (this.context.router && e.button === 0) {
const id = e.currentTarget.getAttribute('data-id'); const id = e.currentTarget.getAttribute('data-id');
e.preventDefault(); e.preventDefault();
this.context.router.history.push(`/accounts/${id}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${id}`, state);
} }
} }
@ -337,11 +343,15 @@ export default class Status extends ImmutablePureComponent {
} }
handleHotkeyOpen = () => { handleHotkeyOpen = () => {
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`, state);
} }
handleHotkeyOpenProfile = () => { handleHotkeyOpenProfile = () => {
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`, state);
} }
handleHotkeyMoveUp = e => { handleHotkeyMoveUp = e => {

+ 3
- 1
app/javascript/flavours/glitch/components/status_action_bar.js View File

@ -150,7 +150,9 @@ export default class StatusActionBar extends ImmutablePureComponent {
} }
handleOpen = () => { handleOpen = () => {
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/statuses/${this.props.status.get('id')}`, state);
} }
handleEmbed = () => { handleEmbed = () => {

+ 3
- 1
app/javascript/flavours/glitch/features/account_timeline/components/moved_note.js View File

@ -20,7 +20,9 @@ export default class MovedNote extends ImmutablePureComponent {
handleAccountClick = e => { handleAccountClick = e => {
if (e.button === 0) { if (e.button === 0) {
e.preventDefault(); e.preventDefault();
this.context.router.history.push(`/accounts/${this.props.to.get('id')}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${this.props.to.get('id')}`, state);
} }
e.stopPropagation(); e.stopPropagation();

+ 6
- 2
app/javascript/flavours/glitch/features/status/components/detailed_status.js View File

@ -42,7 +42,9 @@ export default class DetailedStatus extends ImmutablePureComponent {
handleAccountClick = (e) => { handleAccountClick = (e) => {
if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey) && this.context.router) { if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey) && this.context.router) {
e.preventDefault(); e.preventDefault();
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`, state);
} }
e.stopPropagation(); e.stopPropagation();
@ -51,7 +53,9 @@ export default class DetailedStatus extends ImmutablePureComponent {
parseClick = (e, destination) => { parseClick = (e, destination) => {
if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey) && this.context.router) { if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey) && this.context.router) {
e.preventDefault(); e.preventDefault();
this.context.router.history.push(destination);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(destination, state);
} }
e.stopPropagation(); e.stopPropagation();

+ 3
- 1
app/javascript/flavours/glitch/features/status/index.js View File

@ -331,7 +331,9 @@ export default class Status extends ImmutablePureComponent {
} }
handleHotkeyOpenProfile = () => { handleHotkeyOpenProfile = () => {
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`, state);
} }
handleMoveUp = id => { handleMoveUp = id => {

+ 3
- 1
app/javascript/flavours/glitch/features/ui/components/boost_modal.js View File

@ -40,7 +40,9 @@ export default class BoostModal extends ImmutablePureComponent {
if (e.button === 0) { if (e.button === 0) {
e.preventDefault(); e.preventDefault();
this.props.onClose(); this.props.onClose();
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`, state);
} }
} }

+ 3
- 1
app/javascript/flavours/glitch/features/ui/components/favourite_modal.js View File

@ -40,7 +40,9 @@ export default class FavouriteModal extends ImmutablePureComponent {
if (e.button === 0) { if (e.button === 0) {
e.preventDefault(); e.preventDefault();
this.props.onClose(); this.props.onClose();
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`);
let state = {...this.context.router.history.location.state};
state.mastodonBackSteps = (state.mastodonBackSteps || 0) + 1;
this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`, state);
} }
} }

Loading…
Cancel
Save