improve friendship creation/revokation
This commit is contained in:
parent
b008fd686c
commit
cb0f665f33
|
@ -1,18 +1,21 @@
|
||||||
@(userId: String)(implicit ctx: Context)
|
@(userId: String)(implicit ctx: Context)
|
||||||
|
|
||||||
|
<div class="friend_button">
|
||||||
@friendStatus(userId).map { status =>
|
@friendStatus(userId).map { status =>
|
||||||
@if(status.friends) {
|
@if(status.friends) {
|
||||||
<span class="friend_button">@trans.friends()</span>
|
@trans.friends()
|
||||||
} else {
|
} else {
|
||||||
@if(status.pending) {
|
@if(status.pending) {
|
||||||
<span class="friend_button">@trans.pendingRequest</span>
|
@trans.pendingRequest()
|
||||||
|
<a class="friend_button" href="@routes.Friend.no(userId)">@trans.cancel()</a>
|
||||||
} else {
|
} else {
|
||||||
@if(status.requested) {
|
@if(status.requested) {
|
||||||
<a class="friend_button" href="@routes.Friend.yes(userId)">@trans.accept()</a>
|
<a href="@routes.Friend.yes(userId)">@trans.accept()</a>
|
||||||
<a class="friend_button" href="@routes.Friend.no(userId)">@trans.decline()</a>
|
<a href="@routes.Friend.no(userId)">@trans.decline()</a>
|
||||||
} else {
|
} else {
|
||||||
<a class="friend_button" href="@routes.Friend.yes(userId)">@trans.addFriend()</a>
|
<a href="@routes.Friend.yes(userId)">@trans.addFriend()</a>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</div>
|
||||||
|
|
|
@ -11,4 +11,9 @@ private[friend] final class Cached {
|
||||||
val requestIds = AsyncCache(RequestRepo.requestedUserIds, maxCapacity = 5000)
|
val requestIds = AsyncCache(RequestRepo.requestedUserIds, maxCapacity = 5000)
|
||||||
|
|
||||||
val nbRequests = AsyncCache(RequestRepo.countByFriendId, maxCapacity = 5000)
|
val nbRequests = AsyncCache(RequestRepo.countByFriendId, maxCapacity = 5000)
|
||||||
|
|
||||||
|
private[friend] def invalidate(userId: ID): Funit =
|
||||||
|
friendIds.remove(userId) >>
|
||||||
|
requestIds.remove(userId) >>
|
||||||
|
nbRequests.remove(userId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,9 +64,5 @@ final class FriendApi(cached: Cached) {
|
||||||
accept ?? makeFriends(request.user, request.friend)
|
accept ?? makeFriends(request.user, request.friend)
|
||||||
|
|
||||||
private def invalidate(userIds: String*): Funit =
|
private def invalidate(userIds: String*): Funit =
|
||||||
userIds.toList.map(userId ⇒
|
userIds.toList.map(cached.invalidate).sequence.void
|
||||||
cached.friendIds.remove(userId) >>
|
|
||||||
cached.requestIds.remove(userId) >>
|
|
||||||
cached.nbRequests.remove(userId)
|
|
||||||
).sequence.void
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ private[friend] object FriendRepo {
|
||||||
_.flatten filterNot (userId ==)
|
_.flatten filterNot (userId ==)
|
||||||
}
|
}
|
||||||
|
|
||||||
def add(u1: ID, u2: ID): Funit = $insert(Friend.make(u1, u2))
|
def add(u1: ID, u2: ID): Funit = $insert(Friend.make(u1, u2).pp)
|
||||||
|
|
||||||
def remove(u1: ID, u2: ID): Funit = $remove byId Friend.makeId(u1, u2)
|
def remove(u1: ID, u2: ID): Funit = $remove byId Friend.makeId(u1, u2)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ case class QuickStatus(
|
||||||
friends: Boolean,
|
friends: Boolean,
|
||||||
request: Option[Boolean]) {
|
request: Option[Boolean]) {
|
||||||
|
|
||||||
def requested = ~request
|
def pending = request == Some(true)
|
||||||
|
|
||||||
def pending = request == Some(false)
|
def requested = request == Some(false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,12 +309,12 @@ var lichess_sri = Math.random().toString(36).substring(5); // 8 chars
|
||||||
|
|
||||||
$('#friend_box').friends();
|
$('#friend_box').friends();
|
||||||
|
|
||||||
$('#lichess').on('click', 'a.friend_button', function() {
|
$('#lichess').on('click', 'div.friend_button a', function() {
|
||||||
var $button = $(this);
|
var $a = $(this).text('...');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: $button.attr('href'),
|
url: $a.attr('href'),
|
||||||
type: 'post',
|
type: 'post',
|
||||||
success: function(html) { $button.replaceWith(html); }
|
success: function(html) { $a.parent().replaceWith(html); }
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
1
todo
1
todo
|
@ -65,6 +65,7 @@ from MoralIntentions email:
|
||||||
- Several options of how points should be given to players (for example: Score * Sonneborn-Berger * Tournament Performance Rating * Percentage Score [for example: 0.64] / 1000) and therefore also several Leaderboards.
|
- Several options of how points should be given to players (for example: Score * Sonneborn-Berger * Tournament Performance Rating * Percentage Score [for example: 0.64] / 1000) and therefore also several Leaderboards.
|
||||||
- The possibility of team matches (with solutions for players who are in several teams), where the team leader has to choose the board order, where the team results are shown and where the team player (who has played all of the games of the match) with the highest Percentage Score gets crowned Player of the Match of team "A".
|
- The possibility of team matches (with solutions for players who are in several teams), where the team leader has to choose the board order, where the team results are shown and where the team player (who has played all of the games of the match) with the highest Percentage Score gets crowned Player of the Match of team "A".
|
||||||
safari has high bounce rate
|
safari has high bounce rate
|
||||||
|
send message to sockets when a friendship is created or revoked
|
||||||
|
|
||||||
DEPLOY p21
|
DEPLOY p21
|
||||||
----------
|
----------
|
||||||
|
|
Loading…
Reference in a new issue