about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/actions/markers.js
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-10-09 23:26:02 +0200
committerGitHub <noreply@github.com>2022-10-09 23:26:02 +0200
commit94713940c7f28e9aff50071cf63d897c8e355ee6 (patch)
tree109be3b0d61e50789f69704d9e1c9ffdc7e66141 /app/javascript/flavours/glitch/actions/markers.js
parent44486db912ac6064419680dbc3dcd3843a02a144 (diff)
parentd04fbe6fe06113041662bbd9816198256d3cd385 (diff)
Merge pull request #1861 from ClearlyClaire/glitch-soc/features/logged-out-webui
Port logged-out Web UI to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/actions/markers.js')
-rw-r--r--app/javascript/flavours/glitch/actions/markers.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/actions/markers.js b/app/javascript/flavours/glitch/actions/markers.js
index a086def97..6a0549f7f 100644
--- a/app/javascript/flavours/glitch/actions/markers.js
+++ b/app/javascript/flavours/glitch/actions/markers.js
@@ -1,6 +1,7 @@
 import api from 'flavours/glitch/util/api';
 import { debounce } from 'lodash';
 import compareId from 'flavours/glitch/util/compare_id';
+import { List as ImmutableList } from 'immutable';
 
 export const MARKERS_FETCH_REQUEST = 'MARKERS_FETCH_REQUEST';
 export const MARKERS_FETCH_SUCCESS = 'MARKERS_FETCH_SUCCESS';
@@ -11,7 +12,7 @@ export const synchronouslySubmitMarkers = () => (dispatch, getState) => {
   const accessToken = getState().getIn(['meta', 'access_token'], '');
   const params      = _buildParams(getState());
 
-  if (Object.keys(params).length === 0) {
+  if (Object.keys(params).length === 0 || accessToken === '') {
     return;
   }
 
@@ -63,7 +64,7 @@ export const synchronouslySubmitMarkers = () => (dispatch, getState) => {
 const _buildParams = (state) => {
   const params = {};
 
-  const lastHomeId         = state.getIn(['timelines', 'home', 'items']).find(item => item !== null);
+  const lastHomeId         = state.getIn(['timelines', 'home', 'items'], ImmutableList()).find(item => item !== null);
   const lastNotificationId = state.getIn(['notifications', 'lastReadId']);
 
   if (lastHomeId && compareId(lastHomeId, state.getIn(['markers', 'home'])) > 0) {
@@ -82,9 +83,10 @@ const _buildParams = (state) => {
 };
 
 const debouncedSubmitMarkers = debounce((dispatch, getState) => {
-  const params = _buildParams(getState());
+  const accessToken = getState().getIn(['meta', 'access_token'], '');
+  const params      = _buildParams(getState());
 
-  if (Object.keys(params).length === 0) {
+  if (Object.keys(params).length === 0 || accessToken === '') {
     return;
   }