UNPKG

933 BJavaScriptView Raw
1const SocialCtrl = require('../ssb_ctrl/social');
2
3module.exports = (sbot, myIdent, chessIndex) => {
4 const socialCtrl = SocialCtrl(sbot, myIdent, chessIndex);
5
6 function followedByMe() {
7 return socialCtrl.followedByMe();
8 }
9
10 function identWithDisplayName(ident) {
11 return socialCtrl.getPlayerDisplayName(ident).then(name => ({
12 ident,
13 displayName: name,
14 }));
15 }
16
17 function getDisplayName(id) {
18 return identWithDisplayName(id).then(result => result.displayName);
19 }
20
21 function followedByMeWithNames() {
22 return followedByMe().then((palaroonis) => {
23 const namesWithIdents = palaroonis.map(identWithDisplayName);
24
25 return Promise.all(namesWithIdents);
26 });
27 }
28
29 function getWeightedPlayFrequencyList() {
30 return socialCtrl.getWeightedPlayFrequencyList();
31 }
32
33 return {
34 getWeightedPlayFrequencyList,
35 followedByMe,
36 followedByMeWithNames,
37 getDisplayName,
38 };
39};