import { fetchAndPresentFollowed } from '../services/TagPresenter'
import { get } from 'lodash/fp'

module.exports = {
  show: function (req, res) {
    if (!req.session.userId) return res.ok({})
    const communityId = req.param('communityId')

    return Promise.join(
      User.find(req.session.userId, {withRelated: ['memberships']}),
      communityId && Community.find(communityId),
      (user, com) =>
        fetchAndPresentFollowed(get('id', com), user.id)
        .then(left_nav_tags => res.ok({
          new_notification_count: user.get('new_notification_count'),
          left_nav_tags,
          memberships: user.relations.memberships.map(m => ({
            id: m.id,
            new_notification_count: m.get('new_notification_count')
          }))
        })))
  }
}

@@ -302,40 +302,8 @@
 erId
-, %7BwithRelated: %5B'memberships'%5D%7D
 ),%0A 
@@ -566,175 +566,8 @@
 tags
-,%0A          memberships: user.relations.memberships.map(m =%3E (%7B%0A            id: m.id,%0A            new_notification_count: m.get('new_notification_count')%0A          %7D))
 %0A   

remove memberships from fetchLiveStatus