From 59d943e152a36c693eddd6a6a3c1d9c956dba07b Mon Sep 17 00:00:00 2001
From: Eugen Rochko <eugen@zeonfederated.com>
Date: Mon, 7 Dec 2020 03:23:43 +0100
Subject: [PATCH] Fix alert when failing to save timeline markers in web UI
(#15285)
Fix #15267
---
app/javascript/mastodon/actions/markers.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/app/javascript/mastodon/actions/markers.js b/app/javascript/mastodon/actions/markers.js
index c4b61effdd..16a3df8f63 100644
--- a/app/javascript/mastodon/actions/markers.js
+++ b/app/javascript/mastodon/actions/markers.js
@@ -1,7 +1,6 @@
import api from '../api';
import { debounce } from 'lodash';
import compareId from '../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;
};
--
GitLab