3 var unreadItemService = require('gitter-web-unread-items');
4 var roomMembershipService = require('gitter-web-rooms/lib/room-membership-service');
5 var _ = require('lodash');
7 function LurkAndActivityForUserStrategy(options) {
8 this.currentUserId = options.currentUserId;
9 this.roomsWithLurk = null;
13 LurkAndActivityForUserStrategy.prototype = {
15 return roomMembershipService
16 .findLurkingRoomIdsForUserId(this.currentUserId)
18 .then(function(troupeIds) {
20 this.roomsWithLurk = _.reduce(
22 function(memo, troupeId) {
23 memo[troupeId] = true;
29 // Map the activity indicators
30 return unreadItemService.getActivityIndicatorForTroupeIds(troupeIds, this.currentUserId);
32 .then(function(values) {
33 this.activity = values;
37 mapLurkStatus: function(roomId) {
38 return this.roomsWithLurk[roomId] || false;
41 mapActivity: function(roomId) {
42 return this.activity[roomId];
45 name: 'LurkAndActivityForUserStrategy'
48 module.exports = LurkAndActivityForUserStrategy;