Fix timeline markers not working on Chrome (#13887)

* Periodically save timeline markers

This saves timeline markers immediately upon message arrival, but not more
than once every 5 minutes.

This does not change how the markers are saved on closing the window,
except that it avoids submitting them if there is no need for it.

* Use the Fetch API when possible instead of XHR on window unload
This commit is contained in:
ThibG
2020-05-29 16:14:16 +02:00
committed by GitHub
parent 8bbc81c71e
commit 5aff2a6957
6 changed files with 115 additions and 24 deletions

View File

@ -16,7 +16,7 @@ import { expandNotifications } from '../../actions/notifications';
import { fetchFilters } from '../../actions/filters';
import { clearHeight } from '../../actions/height_cache';
import { focusApp, unfocusApp } from 'mastodon/actions/app';
import { submitMarkers } from 'mastodon/actions/markers';
import { synchronouslySubmitMarkers } from 'mastodon/actions/markers';
import { WrappedSwitch, WrappedRoute } from './util/react_router_helpers';
import UploadArea from './components/upload_area';
import ColumnsAreaContainer from './containers/columns_area_container';
@ -251,7 +251,7 @@ class UI extends React.PureComponent {
handleBeforeUnload = e => {
const { intl, dispatch, isComposing, hasComposingText, hasMediaAttachments } = this.props;
dispatch(submitMarkers());
dispatch(synchronouslySubmitMarkers());
if (isComposing && (hasComposingText || hasMediaAttachments)) {
// Setting returnValue to any string causes confirmation dialog.