diff options
author | David Yip <yipdw@member.fsf.org> | 2018-06-12 16:39:30 -0500 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2018-06-12 16:39:30 -0500 |
commit | e931cf656d1de6d89b5b048d8f1de15be7b52690 (patch) | |
tree | b1c0c66b6a88b56c422ea8be1dbef77e42afae72 /app/javascript/flavours | |
parent | 97d2df77aae687c983c1294ebcd3962e4f9d985c (diff) | |
parent | 34f1fd2a621ca869c17009487e2f10063812fbd0 (diff) |
Merge remote-tracking branch 'glitchsoc/master' into 454-allow-keyword-mutes-to-skip-mentions
Conflicts: app/models/glitch/keyword_mute.rb
Diffstat (limited to 'app/javascript/flavours')
8 files changed, 28 insertions, 47 deletions
diff --git a/app/javascript/flavours/glitch/components/column_back_button.js b/app/javascript/flavours/glitch/components/column_back_button.js index 50c3bf11f..a562ef9b9 100644 --- a/app/javascript/flavours/glitch/components/column_back_button.js +++ b/app/javascript/flavours/glitch/components/column_back_button.js @@ -10,10 +10,10 @@ export default class ColumnBackButton extends React.PureComponent { handleClick = () => { // if history is exhausted, or we would leave mastodon, just go to root. - if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) { - this.context.router.history.push('/'); - } else { + if (window.history.state) { this.context.router.history.goBack(); + } else { + this.context.router.history.push('/'); } } diff --git a/app/javascript/flavours/glitch/components/column_back_button_slim.js b/app/javascript/flavours/glitch/components/column_back_button_slim.js index 2cdf1b25b..c99c202af 100644 --- a/app/javascript/flavours/glitch/components/column_back_button_slim.js +++ b/app/javascript/flavours/glitch/components/column_back_button_slim.js @@ -10,10 +10,10 @@ export default class ColumnBackButtonSlim extends React.PureComponent { handleClick = () => { // if history is exhausted, or we would leave mastodon, just go to root. - if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) { - this.context.router.history.push('/'); - } else { + if (window.history.state) { this.context.router.history.goBack(); + } else { + this.context.router.history.push('/'); } } diff --git a/app/javascript/flavours/glitch/components/column_header.js b/app/javascript/flavours/glitch/components/column_header.js index bfad6467d..72207637d 100644 --- a/app/javascript/flavours/glitch/components/column_header.js +++ b/app/javascript/flavours/glitch/components/column_header.js @@ -66,10 +66,10 @@ export default class ColumnHeader extends React.PureComponent { handleBackClick = () => { // if history is exhausted, or we would leave mastodon, just go to root. - if (window.history && (window.history.length === 1 || window.history.length === window._mastoInitialHistoryLen)) { - this.context.router.history.push('/'); - } else { + if (window.history.state) { this.context.router.history.goBack(); + } else { + this.context.router.history.push('/'); } } diff --git a/app/javascript/flavours/glitch/features/ui/index.js b/app/javascript/flavours/glitch/features/ui/index.js index 0e3a83bb6..4a7a7d0f4 100644 --- a/app/javascript/flavours/glitch/features/ui/index.js +++ b/app/javascript/flavours/glitch/features/ui/index.js @@ -99,10 +99,6 @@ const keyMap = { @withRouter export default class UI extends React.Component { - static contextTypes = { - router: PropTypes.object.isRequired, - }; - static propTypes = { dispatch: PropTypes.func.isRequired, children: PropTypes.node, @@ -113,6 +109,7 @@ export default class UI extends React.Component { isComposing: PropTypes.bool, hasComposingText: PropTypes.bool, location: PropTypes.object, + router: PropTypes.object, intl: PropTypes.object.isRequired, dropdownMenuIsOpen: PropTypes.bool, }; @@ -200,7 +197,7 @@ export default class UI extends React.Component { handleServiceWorkerPostMessage = ({ data }) => { if (data.type === 'navigate') { - this.context.router.history.push(data.path); + this.props.router.history.push(data.path); } else { console.warn('Unknown message type:', data.type); } @@ -305,10 +302,11 @@ export default class UI extends React.Component { } handleHotkeyBack = () => { - if (window.history && window.history.length === 1) { - this.context.router.history.push('/'); - } else { + // if history is exhausted, or we would leave mastodon, just go to root. + if (window.history.state) { this.context.router.history.goBack(); + } else { + this.context.router.history.push('/'); } } @@ -318,54 +316,54 @@ export default class UI extends React.Component { handleHotkeyToggleHelp = () => { if (this.props.location.pathname === '/keyboard-shortcuts') { - this.context.router.history.goBack(); + this.props.router.history.goBack(); } else { - this.context.router.history.push('/keyboard-shortcuts'); + this.props.router.history.push('/keyboard-shortcuts'); } } handleHotkeyGoToHome = () => { - this.context.router.history.push('/timelines/home'); + this.props.router.history.push('/timelines/home'); } handleHotkeyGoToNotifications = () => { - this.context.router.history.push('/notifications'); + this.props.router.history.push('/notifications'); } handleHotkeyGoToLocal = () => { - this.context.router.history.push('/timelines/public/local'); + this.props.router.history.push('/timelines/public/local'); } handleHotkeyGoToFederated = () => { - this.context.router.history.push('/timelines/public'); + this.props.router.history.push('/timelines/public'); } handleHotkeyGoToDirect = () => { - this.context.router.history.push('/timelines/direct'); + this.props.router.history.push('/timelines/direct'); } handleHotkeyGoToStart = () => { - this.context.router.history.push('/getting-started'); + this.props.router.history.push('/getting-started'); } handleHotkeyGoToFavourites = () => { - this.context.router.history.push('/favourites'); + this.props.router.history.push('/favourites'); } handleHotkeyGoToPinned = () => { - this.context.router.history.push('/pinned'); + this.props.router.history.push('/pinned'); } handleHotkeyGoToProfile = () => { - this.context.router.history.push(`/accounts/${me}`); + this.props.router.history.push(`/accounts/${me}`); } handleHotkeyGoToBlocked = () => { - this.context.router.history.push('/blocks'); + this.props.router.history.push('/blocks'); } handleHotkeyGoToMuted = () => { - this.context.router.history.push('/mutes'); + this.props.router.history.push('/mutes'); } render () { diff --git a/app/javascript/flavours/glitch/reducers/accounts.js b/app/javascript/flavours/glitch/reducers/accounts.js index 86f4970c9..2156de029 100644 --- a/app/javascript/flavours/glitch/reducers/accounts.js +++ b/app/javascript/flavours/glitch/reducers/accounts.js @@ -27,7 +27,6 @@ import { FAVOURITES_FETCH_SUCCESS, } from 'flavours/glitch/actions/interactions'; import { - TIMELINE_REFRESH_SUCCESS, TIMELINE_UPDATE, TIMELINE_EXPAND_SUCCESS, } from 'flavours/glitch/actions/timelines'; @@ -38,7 +37,6 @@ import { import { SEARCH_FETCH_SUCCESS } from 'flavours/glitch/actions/search'; import { NOTIFICATIONS_UPDATE, - NOTIFICATIONS_REFRESH_SUCCESS, NOTIFICATIONS_EXPAND_SUCCESS, } from 'flavours/glitch/actions/notifications'; import { @@ -144,11 +142,9 @@ export default function accounts(state = initialState, action) { case LIST_ACCOUNTS_FETCH_SUCCESS: case LIST_EDITOR_SUGGESTIONS_READY: return action.accounts ? normalizeAccounts(state, action.accounts) : state; - case NOTIFICATIONS_REFRESH_SUCCESS: case NOTIFICATIONS_EXPAND_SUCCESS: case SEARCH_FETCH_SUCCESS: return normalizeAccountsFromStatuses(normalizeAccounts(state, action.accounts), action.statuses); - case TIMELINE_REFRESH_SUCCESS: case TIMELINE_EXPAND_SUCCESS: case CONTEXT_FETCH_SUCCESS: case FAVOURITED_STATUSES_FETCH_SUCCESS: diff --git a/app/javascript/flavours/glitch/reducers/accounts_counters.js b/app/javascript/flavours/glitch/reducers/accounts_counters.js index 7abcb5dec..64dff9b55 100644 --- a/app/javascript/flavours/glitch/reducers/accounts_counters.js +++ b/app/javascript/flavours/glitch/reducers/accounts_counters.js @@ -29,7 +29,6 @@ import { FAVOURITES_FETCH_SUCCESS, } from 'flavours/glitch/actions/interactions'; import { - TIMELINE_REFRESH_SUCCESS, TIMELINE_UPDATE, TIMELINE_EXPAND_SUCCESS, } from 'flavours/glitch/actions/timelines'; @@ -40,7 +39,6 @@ import { import { SEARCH_FETCH_SUCCESS } from 'flavours/glitch/actions/search'; import { NOTIFICATIONS_UPDATE, - NOTIFICATIONS_REFRESH_SUCCESS, NOTIFICATIONS_EXPAND_SUCCESS, } from 'flavours/glitch/actions/notifications'; import { @@ -119,11 +117,9 @@ export default function accountsCounters(state = initialState, action) { case LIST_ACCOUNTS_FETCH_SUCCESS: case LIST_EDITOR_SUGGESTIONS_READY: return action.accounts ? normalizeAccounts(state, action.accounts) : state; - case NOTIFICATIONS_REFRESH_SUCCESS: case NOTIFICATIONS_EXPAND_SUCCESS: case SEARCH_FETCH_SUCCESS: return normalizeAccountsFromStatuses(normalizeAccounts(state, action.accounts), action.statuses); - case TIMELINE_REFRESH_SUCCESS: case TIMELINE_EXPAND_SUCCESS: case CONTEXT_FETCH_SUCCESS: case FAVOURITED_STATUSES_FETCH_SUCCESS: diff --git a/app/javascript/flavours/glitch/reducers/statuses.js b/app/javascript/flavours/glitch/reducers/statuses.js index bc5bc1804..94f367d72 100644 --- a/app/javascript/flavours/glitch/reducers/statuses.js +++ b/app/javascript/flavours/glitch/reducers/statuses.js @@ -21,14 +21,12 @@ import { STATUS_UNMUTE_SUCCESS, } from 'flavours/glitch/actions/statuses'; import { - TIMELINE_REFRESH_SUCCESS, TIMELINE_UPDATE, TIMELINE_DELETE, TIMELINE_EXPAND_SUCCESS, } from 'flavours/glitch/actions/timelines'; import { NOTIFICATIONS_UPDATE, - NOTIFICATIONS_REFRESH_SUCCESS, NOTIFICATIONS_EXPAND_SUCCESS, } from 'flavours/glitch/actions/notifications'; import { @@ -129,10 +127,8 @@ export default function statuses(state = initialState, action) { return state.setIn([action.id, 'muted'], true); case STATUS_UNMUTE_SUCCESS: return state.setIn([action.id, 'muted'], false); - case TIMELINE_REFRESH_SUCCESS: case TIMELINE_EXPAND_SUCCESS: case CONTEXT_FETCH_SUCCESS: - case NOTIFICATIONS_REFRESH_SUCCESS: case NOTIFICATIONS_EXPAND_SUCCESS: case FAVOURITED_STATUSES_FETCH_SUCCESS: case FAVOURITED_STATUSES_EXPAND_SUCCESS: diff --git a/app/javascript/flavours/glitch/util/main.js b/app/javascript/flavours/glitch/util/main.js index c00210677..b76826481 100644 --- a/app/javascript/flavours/glitch/util/main.js +++ b/app/javascript/flavours/glitch/util/main.js @@ -28,11 +28,6 @@ function main() { store.dispatch(registerPushNotifications.register()); } perf.stop('main()'); - - // remember the initial URL - if (window.history && typeof window._mastoInitialHistoryLen === 'undefined') { - window._mastoInitialHistoryLen = window.history.length; - } }); } |