From 5963630c6308062ba38d6f527e9d3a38f05df282 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 08:46:35 -0600 Subject: Prevent duplicate load of favourites (tootsuite pr #5931) --- app/javascript/flavours/glitch/actions/favourites.js | 6 +++++- .../flavours/glitch/features/favourited_statuses/index.js | 10 +++++++--- app/javascript/flavours/glitch/reducers/status_lists.js | 12 ++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/actions/favourites.js b/app/javascript/flavours/glitch/actions/favourites.js index decdcee4f..0c0f3af44 100644 --- a/app/javascript/flavours/glitch/actions/favourites.js +++ b/app/javascript/flavours/glitch/actions/favourites.js @@ -10,6 +10,10 @@ export const FAVOURITED_STATUSES_EXPAND_FAIL = 'FAVOURITED_STATUSES_EXPAND_FA export function fetchFavouritedStatuses() { return (dispatch, getState) => { + if (getState().getIn(['status_lists', 'favourites', 'isLoading'])) { + return; + } + dispatch(fetchFavouritedStatusesRequest()); api(getState).get('/api/v1/favourites').then(response => { @@ -46,7 +50,7 @@ export function expandFavouritedStatuses() { return (dispatch, getState) => { const url = getState().getIn(['status_lists', 'favourites', 'next'], null); - if (url === null) { + if (url === null || getState().getIn(['status_lists', 'favourites', 'isLoading'])) { return; } diff --git a/app/javascript/flavours/glitch/features/favourited_statuses/index.js b/app/javascript/flavours/glitch/features/favourited_statuses/index.js index e20dda718..301a5ae4f 100644 --- a/app/javascript/flavours/glitch/features/favourited_statuses/index.js +++ b/app/javascript/flavours/glitch/features/favourited_statuses/index.js @@ -9,6 +9,7 @@ import { addColumn, removeColumn, moveColumn } from 'flavours/glitch/actions/col import StatusList from 'flavours/glitch/components/status_list'; import { defineMessages, injectIntl } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; +import { debounce } from 'lodash'; const messages = defineMessages({ heading: { id: 'column.favourites', defaultMessage: 'Favourites' }, @@ -16,6 +17,7 @@ const messages = defineMessages({ const mapStateToProps = state => ({ statusIds: state.getIn(['status_lists', 'favourites', 'items']), + isLoading: state.getIn(['status_lists', 'favourites', 'isLoading'], true), hasMore: !!state.getIn(['status_lists', 'favourites', 'next']), }); @@ -30,6 +32,7 @@ export default class Favourites extends ImmutablePureComponent { columnId: PropTypes.string, multiColumn: PropTypes.bool, hasMore: PropTypes.bool, + isLoading: PropTypes.bool, }; componentWillMount () { @@ -59,12 +62,12 @@ export default class Favourites extends ImmutablePureComponent { this.column = c; } - handleScrollToBottom = () => { + handleScrollToBottom = debounce(() => { this.props.dispatch(expandFavouritedStatuses()); - } + }, 300, { leading: true }) render () { - const { intl, statusIds, columnId, multiColumn, hasMore } = this.props; + const { intl, statusIds, columnId, multiColumn, hasMore, isLoading } = this.props; const pinned = !!columnId; return ( @@ -85,6 +88,7 @@ export default class Favourites extends ImmutablePureComponent { statusIds={statusIds} scrollKey={`favourited_statuses-${columnId}`} hasMore={hasMore} + isLoading={isLoading} onScrollToBottom={this.handleScrollToBottom} /> diff --git a/app/javascript/flavours/glitch/reducers/status_lists.js b/app/javascript/flavours/glitch/reducers/status_lists.js index 5a3d0db0c..6de81c6b1 100644 --- a/app/javascript/flavours/glitch/reducers/status_lists.js +++ b/app/javascript/flavours/glitch/reducers/status_lists.js @@ -1,6 +1,10 @@ import { + FAVOURITED_STATUSES_FETCH_REQUEST, FAVOURITED_STATUSES_FETCH_SUCCESS, + FAVOURITED_STATUSES_FETCH_FAIL, + FAVOURITED_STATUSES_EXPAND_REQUEST, FAVOURITED_STATUSES_EXPAND_SUCCESS, + FAVOURITED_STATUSES_EXPAND_FAIL, } from 'flavours/glitch/actions/favourites'; import { PINNED_STATUSES_FETCH_SUCCESS, @@ -30,6 +34,7 @@ const normalizeList = (state, listType, statuses, next) => { return state.update(listType, listMap => listMap.withMutations(map => { map.set('next', next); map.set('loaded', true); + map.set('isLoading', false); map.set('items', ImmutableList(statuses.map(item => item.id))); })); }; @@ -37,6 +42,7 @@ const normalizeList = (state, listType, statuses, next) => { const appendToList = (state, listType, statuses, next) => { return state.update(listType, listMap => listMap.withMutations(map => { map.set('next', next); + map.set('isLoading', false); map.set('items', map.get('items').concat(statuses.map(item => item.id))); })); }; @@ -55,6 +61,12 @@ const removeOneFromList = (state, listType, status) => { export default function statusLists(state = initialState, action) { switch(action.type) { + case FAVOURITED_STATUSES_FETCH_REQUEST: + case FAVOURITED_STATUSES_EXPAND_REQUEST: + return state.setIn(['favourites', 'isLoading'], true); + case FAVOURITED_STATUSES_FETCH_FAIL: + case FAVOURITED_STATUSES_EXPAND_FAIL: + return state.setIn(['favourites', 'isLoading'], false); case FAVOURITED_STATUSES_FETCH_SUCCESS: return normalizeList(state, 'favourites', action.statuses, action.next); case FAVOURITED_STATUSES_EXPAND_SUCCESS: -- cgit From 8a0e4bb9a4007efb2c2966fa1ffa9027a1a6da5d Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 08:50:55 -0600 Subject: Hide moved account's follow button in search result (tootsuite pr #5913) --- app/javascript/flavours/glitch/components/account.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/components/account.js b/app/javascript/flavours/glitch/components/account.js index bb1979cc7..265ee94f6 100644 --- a/app/javascript/flavours/glitch/components/account.js +++ b/app/javascript/flavours/glitch/components/account.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import PropTypes from 'prop-types'; import Avatar from './avatar'; @@ -94,12 +94,12 @@ export default class Account extends ImmutablePureComponent { hidingNotificationsButton = ; } buttons = ( -
+ {hidingNotificationsButton} -
+ ); - } else { + } else if (!account.get('moved')) { buttons = ; } } -- cgit From 7f4374d97dd7dce6ec9f632a3cc8527490cbe2c6 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 08:52:14 -0600 Subject: Fix newlines-to-spaces functionality (tootsuite pr #6158) --- app/javascript/flavours/glitch/actions/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/actions/notifications.js b/app/javascript/flavours/glitch/actions/notifications.js index 9b9ebf86d..cf27eff90 100644 --- a/app/javascript/flavours/glitch/actions/notifications.js +++ b/app/javascript/flavours/glitch/actions/notifications.js @@ -42,7 +42,7 @@ const fetchRelatedRelationships = (dispatch, notifications) => { const unescapeHTML = (html) => { const wrapper = document.createElement('div'); - html = html.replace(/
|
|\n/, ' '); + html = html.replace(/
|
|\n/g, ' '); wrapper.innerHTML = html; return wrapper.textContent; }; -- cgit From 6d1c325167d12300e86d678a054777acd5d3077a Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 09:48:14 -0600 Subject: Rename key to path in actions and reducers for settings (tootsuite pr #6105) --- .../flavours/glitch/actions/push_notifications/index.js | 4 ++-- .../flavours/glitch/actions/push_notifications/setter.js | 4 ++-- app/javascript/flavours/glitch/actions/settings.js | 6 +++--- .../glitch/features/notifications/components/column_settings.js | 4 ++-- .../notifications/containers/column_settings_container.js | 8 ++++---- app/javascript/flavours/glitch/reducers/push_notifications.js | 2 +- app/javascript/flavours/glitch/reducers/settings.js | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/actions/push_notifications/index.js b/app/javascript/flavours/glitch/actions/push_notifications/index.js index 376b55b62..2ffec500a 100644 --- a/app/javascript/flavours/glitch/actions/push_notifications/index.js +++ b/app/javascript/flavours/glitch/actions/push_notifications/index.js @@ -15,9 +15,9 @@ export { register, }; -export function changeAlerts(key, value) { +export function changeAlerts(path, value) { return dispatch => { - dispatch(setAlerts(key, value)); + dispatch(setAlerts(path, value)); dispatch(saveSettings()); }; } diff --git a/app/javascript/flavours/glitch/actions/push_notifications/setter.js b/app/javascript/flavours/glitch/actions/push_notifications/setter.js index a2cc41c5a..5561766bf 100644 --- a/app/javascript/flavours/glitch/actions/push_notifications/setter.js +++ b/app/javascript/flavours/glitch/actions/push_notifications/setter.js @@ -23,11 +23,11 @@ export function clearSubscription () { }; } -export function setAlerts (key, value) { +export function setAlerts (path, value) { return dispatch => { dispatch({ type: SET_ALERTS, - key, + path, value, }); }; diff --git a/app/javascript/flavours/glitch/actions/settings.js b/app/javascript/flavours/glitch/actions/settings.js index 79adca18c..aeef43527 100644 --- a/app/javascript/flavours/glitch/actions/settings.js +++ b/app/javascript/flavours/glitch/actions/settings.js @@ -4,11 +4,11 @@ import { debounce } from 'lodash'; export const SETTING_CHANGE = 'SETTING_CHANGE'; export const SETTING_SAVE = 'SETTING_SAVE'; -export function changeSetting(key, value) { +export function changeSetting(path, value) { return dispatch => { dispatch({ type: SETTING_CHANGE, - key, + path, value, }); @@ -21,7 +21,7 @@ const debouncedSave = debounce((dispatch, getState) => { return; } - const data = getState().get('settings').filter((_, key) => key !== 'saved').toJS(); + const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS(); axios.put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE })); }, 5000, { trailing: true }); diff --git a/app/javascript/flavours/glitch/features/notifications/components/column_settings.js b/app/javascript/flavours/glitch/features/notifications/components/column_settings.js index 23545185c..d9638aaf3 100644 --- a/app/javascript/flavours/glitch/features/notifications/components/column_settings.js +++ b/app/javascript/flavours/glitch/features/notifications/components/column_settings.js @@ -14,8 +14,8 @@ export default class ColumnSettings extends React.PureComponent { onClear: PropTypes.func.isRequired, }; - onPushChange = (key, checked) => { - this.props.onChange(['push', ...key], checked); + onPushChange = (path, checked) => { + this.props.onChange(['push', ...path], checked); } render () { diff --git a/app/javascript/flavours/glitch/features/notifications/containers/column_settings_container.js b/app/javascript/flavours/glitch/features/notifications/containers/column_settings_container.js index 95109fe4d..9585ea556 100644 --- a/app/javascript/flavours/glitch/features/notifications/containers/column_settings_container.js +++ b/app/javascript/flavours/glitch/features/notifications/containers/column_settings_container.js @@ -18,11 +18,11 @@ const mapStateToProps = state => ({ const mapDispatchToProps = (dispatch, { intl }) => ({ - onChange (key, checked) { - if (key[0] === 'push') { - dispatch(changePushNotifications(key.slice(1), checked)); + onChange (path, checked) { + if (path[0] === 'push') { + dispatch(changePushNotifications(path.slice(1), checked)); } else { - dispatch(changeSetting(['notifications', ...key], checked)); + dispatch(changeSetting(['notifications', ...path], checked)); } }, diff --git a/app/javascript/flavours/glitch/reducers/push_notifications.js b/app/javascript/flavours/glitch/reducers/push_notifications.js index 4eba2a5e8..1b47ca962 100644 --- a/app/javascript/flavours/glitch/reducers/push_notifications.js +++ b/app/javascript/flavours/glitch/reducers/push_notifications.js @@ -44,7 +44,7 @@ export default function push_subscriptions(state = initialState, action) { case CLEAR_SUBSCRIPTION: return initialState; case SET_ALERTS: - return state.setIn(action.key, action.value); + return state.setIn(action.path, action.value); default: return state; } diff --git a/app/javascript/flavours/glitch/reducers/settings.js b/app/javascript/flavours/glitch/reducers/settings.js index aaf7938df..c04f262da 100644 --- a/app/javascript/flavours/glitch/reducers/settings.js +++ b/app/javascript/flavours/glitch/reducers/settings.js @@ -101,7 +101,7 @@ export default function settings(state = initialState, action) { return hydrate(state, action.state.get('settings')); case SETTING_CHANGE: return state - .setIn(action.key, action.value) + .setIn(action.path, action.value) .set('saved', false); case COLUMN_ADD: return state -- cgit From 0d4dcb5fb2952943c7d43485dffed8f0fe497ac6 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 09:58:40 -0600 Subject: change key to path in timeline settings containers --- .../community_timeline/containers/column_settings_container.js | 4 ++-- .../features/direct_timeline/containers/column_settings_container.js | 4 ++-- .../features/home_timeline/containers/column_settings_container.js | 4 ++-- .../features/public_timeline/containers/column_settings_container.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/features/community_timeline/containers/column_settings_container.js b/app/javascript/flavours/glitch/features/community_timeline/containers/column_settings_container.js index 84234a836..39387abb9 100644 --- a/app/javascript/flavours/glitch/features/community_timeline/containers/column_settings_container.js +++ b/app/javascript/flavours/glitch/features/community_timeline/containers/column_settings_container.js @@ -8,8 +8,8 @@ const mapStateToProps = state => ({ const mapDispatchToProps = dispatch => ({ - onChange (key, checked) { - dispatch(changeSetting(['community', ...key], checked)); + onChange (path, checked) { + dispatch(changeSetting(['community', ...path], checked)); }, }); diff --git a/app/javascript/flavours/glitch/features/direct_timeline/containers/column_settings_container.js b/app/javascript/flavours/glitch/features/direct_timeline/containers/column_settings_container.js index d3e4b4216..7292af264 100644 --- a/app/javascript/flavours/glitch/features/direct_timeline/containers/column_settings_container.js +++ b/app/javascript/flavours/glitch/features/direct_timeline/containers/column_settings_container.js @@ -8,8 +8,8 @@ const mapStateToProps = state => ({ const mapDispatchToProps = dispatch => ({ - onChange (key, checked) { - dispatch(changeSetting(['direct', ...key], checked)); + onChange (path, checked) { + dispatch(changeSetting(['direct', ...path], checked)); }, }); diff --git a/app/javascript/flavours/glitch/features/home_timeline/containers/column_settings_container.js b/app/javascript/flavours/glitch/features/home_timeline/containers/column_settings_container.js index 19a8e792f..16747151b 100644 --- a/app/javascript/flavours/glitch/features/home_timeline/containers/column_settings_container.js +++ b/app/javascript/flavours/glitch/features/home_timeline/containers/column_settings_container.js @@ -8,8 +8,8 @@ const mapStateToProps = state => ({ const mapDispatchToProps = dispatch => ({ - onChange (key, checked) { - dispatch(changeSetting(['home', ...key], checked)); + onChange (path, checked) { + dispatch(changeSetting(['home', ...path], checked)); }, onSave () { diff --git a/app/javascript/flavours/glitch/features/public_timeline/containers/column_settings_container.js b/app/javascript/flavours/glitch/features/public_timeline/containers/column_settings_container.js index b13e20645..f042adbe6 100644 --- a/app/javascript/flavours/glitch/features/public_timeline/containers/column_settings_container.js +++ b/app/javascript/flavours/glitch/features/public_timeline/containers/column_settings_container.js @@ -8,8 +8,8 @@ const mapStateToProps = state => ({ const mapDispatchToProps = dispatch => ({ - onChange (key, checked) { - dispatch(changeSetting(['public', ...key], checked)); + onChange (path, checked) { + dispatch(changeSetting(['public', ...path], checked)); }, }); -- cgit From b535f24fe568c18097d109f8b5abe2b8f3359c69 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 10:35:36 -0600 Subject: Use const instead of let for constant (tootsuite pr #6106) --- app/javascript/flavours/glitch/features/getting_started/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/features/getting_started/index.js b/app/javascript/flavours/glitch/features/getting_started/index.js index 1b05c4da1..0337e7a43 100644 --- a/app/javascript/flavours/glitch/features/getting_started/index.js +++ b/app/javascript/flavours/glitch/features/getting_started/index.js @@ -79,8 +79,8 @@ export default class GettingStarted extends ImmutablePureComponent { render () { const { intl, myAccount, columns, multiColumn, lists } = this.props; - let navItems = []; - let listItems = []; + const navItems = []; + const listItems = []; if (multiColumn) { if (!columns.find(item => item.get('id') === 'HOME')) { -- cgit From 9bdbe663163d41ef2fe06e6b4b7994c469639457 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 10:37:27 -0600 Subject: Set background to the navigation of Getting Started column (tootsuite pr #6163) --- app/javascript/flavours/glitch/styles/components/index.scss | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/styles/components/index.scss b/app/javascript/flavours/glitch/styles/components/index.scss index fae42d45a..ca6fd9e99 100644 --- a/app/javascript/flavours/glitch/styles/components/index.scss +++ b/app/javascript/flavours/glitch/styles/components/index.scss @@ -1881,6 +1881,11 @@ cursor: default; } +.getting-started__wrapper, +.getting_started { + background: $ui-base-color; +} + .getting-started__wrapper { position: relative; overflow-y: auto; -- cgit From f43c2f12f38aef0d4a909f6f12968cd7bccfef98 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 10:40:14 -0600 Subject: Fix overflowing audit logs (tootsuite pr #6184) --- app/javascript/flavours/glitch/styles/admin.scss | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/styles/admin.scss b/app/javascript/flavours/glitch/styles/admin.scss index 4e923bb98..bdfa50814 100644 --- a/app/javascript/flavours/glitch/styles/admin.scss +++ b/app/javascript/flavours/glitch/styles/admin.scss @@ -396,10 +396,12 @@ } } + &__content { + max-width: calc(100% - 90px); + } + &__title { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; + word-wrap: break-word; } &__timestamp { @@ -413,7 +415,7 @@ color: $ui-primary-color; font-family: 'mastodon-font-monospace', monospace; font-size: 12px; - white-space: nowrap; + word-wrap: break-word; min-height: 20px; } -- cgit From aef4b1af666f3fe66778bff0bab83b780fc71732 Mon Sep 17 00:00:00 2001 From: cwm Date: Tue, 9 Jan 2018 10:51:14 -0600 Subject: Refactor /api/web APIs to use the centralized axios instance (tootsuite pr #6223) --- .../flavours/glitch/actions/push_notifications/registerer.js | 12 ++++++------ app/javascript/flavours/glitch/actions/settings.js | 4 ++-- .../flavours/glitch/features/getting_started/index.js | 2 +- .../flavours/glitch/features/ui/components/embed_modal.js | 4 ++-- app/javascript/flavours/glitch/util/api.js | 12 ++++++++++-- 5 files changed, 21 insertions(+), 13 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/actions/push_notifications/registerer.js b/app/javascript/flavours/glitch/actions/push_notifications/registerer.js index 3003d4149..5ad11f73f 100644 --- a/app/javascript/flavours/glitch/actions/push_notifications/registerer.js +++ b/app/javascript/flavours/glitch/actions/push_notifications/registerer.js @@ -1,4 +1,4 @@ -import axios from 'axios'; +import api from 'flavours/glitch/util/api'; import { pushNotificationsSetting } from 'flavours/glitch/util/settings'; import { setBrowserSupport, setSubscription, clearSubscription } from './setter'; @@ -35,7 +35,7 @@ const subscribe = (registration) => const unsubscribe = ({ registration, subscription }) => subscription ? subscription.unsubscribe().then(() => registration) : registration; -const sendSubscriptionToBackend = (subscription, me) => { +const sendSubscriptionToBackend = (getState, subscription, me) => { const params = { subscription }; if (me) { @@ -45,7 +45,7 @@ const sendSubscriptionToBackend = (subscription, me) => { } } - return axios.post('/api/web/push_subscriptions', params).then(response => response.data); + return api(getState).post('/api/web/push_subscriptions', params).then(response => response.data); }; // Last one checks for payload support: https://web-push-book.gauntface.com/chapter-06/01-non-standards-browsers/#no-payload @@ -85,13 +85,13 @@ export function register () { } else { // Something went wrong, try to subscribe again return unsubscribe({ registration, subscription }).then(subscribe).then( - subscription => sendSubscriptionToBackend(subscription, me)); + subscription => sendSubscriptionToBackend(getState, subscription, me)); } } // No subscription, try to subscribe return subscribe(registration).then( - subscription => sendSubscriptionToBackend(subscription, me)); + subscription => sendSubscriptionToBackend(getState, subscription, me)); }) .then(subscription => { // If we got a PushSubscription (and not a subscription object from the backend) @@ -137,7 +137,7 @@ export function saveSettings() { const alerts = state.get('alerts'); const data = { alerts }; - axios.put(`/api/web/push_subscriptions/${subscription.get('id')}`, { + api(getState).put(`/api/web/push_subscriptions/${subscription.get('id')}`, { data, }).then(() => { const me = getState().getIn(['meta', 'me']); diff --git a/app/javascript/flavours/glitch/actions/settings.js b/app/javascript/flavours/glitch/actions/settings.js index aeef43527..87b2ae76d 100644 --- a/app/javascript/flavours/glitch/actions/settings.js +++ b/app/javascript/flavours/glitch/actions/settings.js @@ -1,4 +1,4 @@ -import axios from 'axios'; +import api from 'flavours/glitch/util/api'; import { debounce } from 'lodash'; export const SETTING_CHANGE = 'SETTING_CHANGE'; @@ -23,7 +23,7 @@ const debouncedSave = debounce((dispatch, getState) => { const data = getState().get('settings').filter((_, path) => path !== 'saved').toJS(); - axios.put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE })); + api(getState).put('/api/web/settings', { data }).then(() => dispatch({ type: SETTING_SAVE })); }, 5000, { trailing: true }); export function saveSettings() { diff --git a/app/javascript/flavours/glitch/features/getting_started/index.js b/app/javascript/flavours/glitch/features/getting_started/index.js index 0337e7a43..0077f193b 100644 --- a/app/javascript/flavours/glitch/features/getting_started/index.js +++ b/app/javascript/flavours/glitch/features/getting_started/index.js @@ -80,7 +80,7 @@ export default class GettingStarted extends ImmutablePureComponent { const { intl, myAccount, columns, multiColumn, lists } = this.props; const navItems = []; - const listItems = []; + let listItems = []; if (multiColumn) { if (!columns.find(item => item.get('id') === 'HOME')) { diff --git a/app/javascript/flavours/glitch/features/ui/components/embed_modal.js b/app/javascript/flavours/glitch/features/ui/components/embed_modal.js index 1afffb51b..f3553f4a9 100644 --- a/app/javascript/flavours/glitch/features/ui/components/embed_modal.js +++ b/app/javascript/flavours/glitch/features/ui/components/embed_modal.js @@ -2,7 +2,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { FormattedMessage, injectIntl } from 'react-intl'; -import axios from 'axios'; +import api from 'flavours/glitch/util/api'; @injectIntl export default class EmbedModal extends ImmutablePureComponent { @@ -23,7 +23,7 @@ export default class EmbedModal extends ImmutablePureComponent { this.setState({ loading: true }); - axios.post('/api/web/embed', { url }).then(res => { + api().post('/api/web/embed', { url }).then(res => { this.setState({ loading: false, oembed: res.data }); const iframeDocument = this.iframe.contentWindow.document; diff --git a/app/javascript/flavours/glitch/util/api.js b/app/javascript/flavours/glitch/util/api.js index ecc703c0a..0be08d7fd 100644 --- a/app/javascript/flavours/glitch/util/api.js +++ b/app/javascript/flavours/glitch/util/api.js @@ -1,4 +1,5 @@ import axios from 'axios'; +import ready from './ready'; import LinkHeader from './link_header'; export const getLinks = response => { @@ -11,10 +12,17 @@ export const getLinks = response => { return LinkHeader.parse(value); }; +let csrfHeader = {}; +function setCSRFHeader() { + const csrfToken = document.querySelector('meta[name=csrf-token]').content; + csrfHeader['X-CSRF-Token'] = csrfToken; +} +ready(setCSRFHeader); + export default getState => axios.create({ - headers: { + headers: Object.assign(csrfHeader, getState ? { 'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`, - }, + } : {}), transformResponse: [function (data) { try { -- cgit