about summary refs log tree commit diff
path: root/app/javascript/mastodon/reducers/markers.js
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-05-29 16:14:16 +0200
committerGitHub <noreply@github.com>2020-05-29 16:14:16 +0200
commit5aff2a6957e861162d67c4610277e9bb2a6f8186 (patch)
tree4538c14ca0428d99749c86a1634efd4263e490c8 /app/javascript/mastodon/reducers/markers.js
parent8bbc81c71e245c47a98b1de833557b38ad64a55d (diff)
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
Diffstat (limited to 'app/javascript/mastodon/reducers/markers.js')
-rw-r--r--app/javascript/mastodon/reducers/markers.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/javascript/mastodon/reducers/markers.js b/app/javascript/mastodon/reducers/markers.js
new file mode 100644
index 000000000..2e67be82e
--- /dev/null
+++ b/app/javascript/mastodon/reducers/markers.js
@@ -0,0 +1,25 @@
+import {
+  MARKERS_SUBMIT_SUCCESS,
+} from '../actions/notifications';
+
+const initialState = ImmutableMap({
+  home: '0',
+  notifications: '0',
+});
+
+import { Map as ImmutableMap } from 'immutable';
+
+export default function markers(state = initialState, action) {
+  switch(action.type) {
+  case MARKERS_SUBMIT_SUCCESS:
+    if (action.home) {
+      state = state.set('home', action.home);
+    }
+    if (action.notifications) {
+      state = state.set('notifications', action.notifications);
+    }
+    return state;
+  default:
+    return state;
+  }
+};