3 var Promise = require('bluebird');
4 var TroupeIdStrategy = require('./troupe-id-strategy');
5 var UserIdStrategy = require('./user-id-strategy');
7 function SampleChatStrategy() {
8 var userStrategy = new UserIdStrategy();
9 var troupeStrategy = new TroupeIdStrategy();
11 this.preload = function(items) {
12 var userIds = items.map(function(i) {
15 var troupeIds = items.map(function(i) {
19 return Promise.join(userStrategy.preload(userIds), troupeStrategy.preload(troupeIds));
22 this.map = function(item) {
23 var user = userStrategy.map(item.fromUserId);
24 var troupe = troupeStrategy.map(item.toTroupeId);
26 if (!user || !troupe || !troupe.uri) return;
28 avatarUrl: user.avatarUrlSmall,
29 username: user.username,
30 displayName: user.displayName,
36 SampleChatStrategy.prototype = {
37 name: 'SampleChatStrategy'
40 module.exports = SampleChatStrategy;