From b5134595d80429177ca7e27f4f38f19dfaab28da Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 7 Dec 2020 03:23:43 +0100 Subject: [Glitch] Fix alert when failing to save timeline markers in web UI Port 59d943e152a36c693eddd6a6a3c1d9c956dba07b to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/actions/markers.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'app/javascript/flavours/glitch') diff --git a/app/javascript/flavours/glitch/actions/markers.js b/app/javascript/flavours/glitch/actions/markers.js index c0e7a93af..a086def97 100644 --- a/app/javascript/flavours/glitch/actions/markers.js +++ b/app/javascript/flavours/glitch/actions/markers.js @@ -1,7 +1,6 @@ import api from 'flavours/glitch/util/api'; import { debounce } from 'lodash'; import compareId from 'flavours/glitch/util/compare_id'; -import { showAlertForError } from './alerts'; export const MARKERS_FETCH_REQUEST = 'MARKERS_FETCH_REQUEST'; export const MARKERS_FETCH_SUCCESS = 'MARKERS_FETCH_SUCCESS'; @@ -29,15 +28,19 @@ export const synchronouslySubmitMarkers = () => (dispatch, getState) => { }, body: JSON.stringify(params), }); + return; } else if (navigator && navigator.sendBeacon) { // Failing that, we can use sendBeacon, but we have to encode the data as // FormData for DoorKeeper to recognize the token. const formData = new FormData(); + formData.append('bearer_token', accessToken); + for (const [id, value] of Object.entries(params)) { formData.append(`${id}[last_read_id]`, value.last_read_id); } + if (navigator.sendBeacon('/api/v1/markers', formData)) { return; } @@ -85,11 +88,9 @@ const debouncedSubmitMarkers = debounce((dispatch, getState) => { return; } - api().post('/api/v1/markers', params).then(() => { + api(getState).post('/api/v1/markers', params).then(() => { dispatch(submitMarkersSuccess(params)); - }).catch(error => { - dispatch(showAlertForError(error)); - }); + }).catch(() => {}); }, 300000, { leading: true, trailing: true }); export function submitMarkersSuccess({ home, notifications }) { @@ -102,9 +103,11 @@ export function submitMarkersSuccess({ home, notifications }) { export function submitMarkers(params = {}) { const result = (dispatch, getState) => debouncedSubmitMarkers(dispatch, getState); + if (params.immediate === true) { debouncedSubmitMarkers.flush(); } + return result; }; -- cgit From 3449ffa13360abe2505d613c3b8f6be09f45e8f7 Mon Sep 17 00:00:00 2001 From: trwnh Date: Tue, 8 Dec 2020 21:34:17 -0600 Subject: [Glitch] rename replies_policy enumerables Port front-end changes from 127c543a6e59d20de68e6760e952d18ed53578e9 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/features/list_timeline/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/javascript/flavours/glitch') diff --git a/app/javascript/flavours/glitch/features/list_timeline/index.js b/app/javascript/flavours/glitch/features/list_timeline/index.js index 70e530bae..d826c8ccd 100644 --- a/app/javascript/flavours/glitch/features/list_timeline/index.js +++ b/app/javascript/flavours/glitch/features/list_timeline/index.js @@ -19,9 +19,9 @@ import RadioButton from 'flavours/glitch/components/radio_button'; const messages = defineMessages({ deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' }, deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' }, - all_replies: { id: 'lists.replies_policy.all_replies', defaultMessage: 'Any followed user' }, - no_replies: { id: 'lists.replies_policy.no_replies', defaultMessage: 'No one' }, - list_replies: { id: 'lists.replies_policy.list_replies', defaultMessage: 'Members of the list' }, + followed: { id: 'lists.replies_policy.followed', defaultMessage: 'Any followed user' }, + none: { id: 'lists.replies_policy.none', defaultMessage: 'No one' }, + list: { id: 'lists.replies_policy.list', defaultMessage: 'Members of the list' }, }); const mapStateToProps = (state, props) => ({ @@ -193,7 +193,7 @@ class ListTimeline extends React.PureComponent {
- { ['no_replies', 'list_replies', 'all_replies'].map(policy => ( + { ['none', 'list', 'followed'].map(policy => ( ))}
-- cgit From e18f9f822834a4467a6b226e84f40a7790f9c9f5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 7 Dec 2020 19:36:36 +0100 Subject: [Glitch] Fix unnecessary re-rendering of various components when typing in web UI Partially port 9620ee90be7e04b3616ce4b851abb63dbba7af7f to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/features/ui/components/columns_area.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/javascript/flavours/glitch') diff --git a/app/javascript/flavours/glitch/features/ui/components/columns_area.js b/app/javascript/flavours/glitch/features/ui/components/columns_area.js index 729ade212..5c2e387a5 100644 --- a/app/javascript/flavours/glitch/features/ui/components/columns_area.js +++ b/app/javascript/flavours/glitch/features/ui/components/columns_area.js @@ -99,8 +99,13 @@ class ColumnsArea extends ImmutablePureComponent { if (this.props.singleColumn !== prevProps.singleColumn && !this.props.singleColumn) { this.node.addEventListener('wheel', this.handleWheel, supportsPassiveEvents ? { passive: true } : false); } - this.lastIndex = getIndex(this.context.router.history.location.pathname); - this.setState({ shouldAnimate: true }); + + const newIndex = getIndex(this.context.router.history.location.pathname); + + if (this.lastIndex !== newIndex) { + this.lastIndex = newIndex; + this.setState({ shouldAnimate: true }); + } } componentWillUnmount () { -- cgit From 7d0e45a3be167d95cbc4d5f80fa989a9371802ae Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 7 Dec 2020 20:07:24 +0100 Subject: [Glitch] Fix column swiping animation logic Port 0b437325dc93a1d28202b5ff30eaafc9b4e571b7 to glitch-soc Co-authored-by: Claire Signed-off-by: Claire --- app/javascript/flavours/glitch/features/ui/components/columns_area.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/javascript/flavours/glitch') diff --git a/app/javascript/flavours/glitch/features/ui/components/columns_area.js b/app/javascript/flavours/glitch/features/ui/components/columns_area.js index 5c2e387a5..640be19ab 100644 --- a/app/javascript/flavours/glitch/features/ui/components/columns_area.js +++ b/app/javascript/flavours/glitch/features/ui/components/columns_area.js @@ -75,7 +75,9 @@ class ColumnsArea extends ImmutablePureComponent { } componentWillReceiveProps() { - this.setState({ shouldAnimate: false }); + if (typeof this.pendingIndex !== 'number' && this.lastIndex !== getIndex(this.context.router.history.location.pathname)) { + this.setState({ shouldAnimate: false }); + } } componentDidMount() { -- cgit