]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Check existence of timeline state in community timeline
authorYamagishi Kazutoshi <ykzts@desire.sh>
Wed, 18 Sep 2019 02:02:21 +0000 (11:02 +0900)
committerThibaut Girka <thib@sitedethib.com>
Wed, 18 Sep 2019 15:27:51 +0000 (17:27 +0200)
Port 0627252b30d9f420d51bb4787c539550d68a717a to glitch-soc

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

index 11b67fa6a4eab202ddf4541eef5d20d47c7655ac..5585edc9c3f450e0ef26d6d284f47df975e4d0ce 100644 (file)
@@ -18,9 +18,10 @@ const mapStateToProps = (state, { onlyMedia, columnId }) => {
   const uuid = columnId;
   const columns = state.getIn(['settings', 'columns']);
   const index = columns.findIndex(c => c.get('uuid') === uuid);
+  const timelineState = state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`]);
 
   return {
-    hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0 || state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'pendingItems']).size > 0,
+    hasUnread: !!timelineState && (timelineState.get('unread') > 0 || timelineState.get('pendingItems').size > 0),
     onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']),
   };
 };