]> cat aescling's git repositories - mastodon.git/commitdiff
Fix mark as read in notifications to be saved immediately (#14907)
authorTakeshi Umeda <noel.yoshiba@gmail.com>
Thu, 1 Oct 2020 02:17:46 +0000 (11:17 +0900)
committerGitHub <noreply@github.com>
Thu, 1 Oct 2020 02:17:46 +0000 (04:17 +0200)
* Fix mark as read in notifications to be saved immediately

* fix code style

app/javascript/mastodon/actions/markers.js
app/javascript/mastodon/features/notifications/index.js
app/javascript/mastodon/features/ui/index.js

index 41a95503eb63b6b09cdfd4c1d229a1a9660a85b5..c4b61effdd77ed07e07f375a0582a8d49c0257cb 100644 (file)
@@ -100,8 +100,12 @@ export function submitMarkersSuccess({ home, notifications }) {
   };
 };
 
-export function submitMarkers() {
-  return (dispatch, getState) => debouncedSubmitMarkers(dispatch, getState);
+export function submitMarkers(params = {}) {
+  const result = (dispatch, getState) => debouncedSubmitMarkers(dispatch, getState);
+  if (params.immediate === true) {
+    debouncedSubmitMarkers.flush();
+  }
+  return result;
 };
 
 export const fetchMarkers = () => (dispatch, getState) => {
index 41a45b2b6c3cf3713ec52765639a832741a2ec5f..68afe593d2ff8dc6ab125458edca69375aeffc93 100644 (file)
@@ -12,6 +12,7 @@ import {
   unmountNotifications,
   markNotificationsAsRead,
 } from '../../actions/notifications';
+import { submitMarkers } from '../../actions/markers';
 import { addColumn, removeColumn, moveColumn } from '../../actions/columns';
 import NotificationContainer from './containers/notification_container';
 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
@@ -162,6 +163,7 @@ class Notifications extends React.PureComponent {
 
   handleMarkAsRead = () => {
     this.props.dispatch(markNotificationsAsRead());
+    this.props.dispatch(submitMarkers({ immediate: true }));
   };
 
   render () {
index d05133507fb2763c17c4cb644d8f3f1d51ef08fc..b53e319d26a1b74a6ea9ee42d1540927243778fa 100644 (file)
@@ -266,7 +266,7 @@ class UI extends React.PureComponent {
 
   handleWindowFocus = () => {
     this.props.dispatch(focusApp());
-    this.props.dispatch(submitMarkers());
+    this.props.dispatch(submitMarkers({ immediate: true }));
   }
 
   handleWindowBlur = () => {