]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix mark as read in notifications to be saved immediately
authorTakeshi Umeda <noel.yoshiba@gmail.com>
Thu, 1 Oct 2020 02:17:46 +0000 (11:17 +0900)
committerThibaut Girka <thib@sitedethib.com>
Wed, 21 Oct 2020 17:33:20 +0000 (19:33 +0200)
Port bec8b12bb52a57b54b66899b2650a5611d9bd561 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/actions/markers.js
app/javascript/flavours/glitch/features/notifications/index.js
app/javascript/flavours/glitch/features/ui/index.js

index 80bcada6edaa45a10be4660d682f48c64c794508..c0e7a93af6af41737af0018acf84b691cb4ecc01 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 475968caa6dc382751f8a9c1709008201c99bed8..18db7e0d24605e066895c1c08e1c966444aca51b 100644 (file)
@@ -71,7 +71,7 @@ const mapDispatchToProps = dispatch => ({
   },
   onMarkAsRead() {
     dispatch(markNotificationsAsRead());
-    dispatch(submitMarkers());
+    dispatch(submitMarkers({ immediate: true }));
   },
   onMount() {
     dispatch(mountNotifications());
index a399fc2b38b5436c1ff0dee86f2e07435530a6e7..fa4068fa34d4876eb50d95e596a02c7f1a93abf5 100644 (file)
@@ -359,7 +359,7 @@ class UI extends React.Component {
     const visibility = !document[this.visibilityHiddenProp];
     this.props.dispatch(notificationsSetVisibility(visibility));
     if (visibility) {
-      this.props.dispatch(submitMarkers());
+      this.props.dispatch(submitMarkers({ immediate: true }));
     }
   }