chg: usr: fine-tune the recent battle list #8
All checks were successful
Deploy to Production / deploy (push) Successful in 27s
All checks were successful
Deploy to Production / deploy (push) Successful in 27s
This commit is contained in:
@@ -69,9 +69,11 @@ export const BattleDialog = ({ games }) => {
|
|||||||
const endReason = resign
|
const endReason = resign
|
||||||
? `${resign.charAt(0).toUpperCase() + resign.slice(1)} resigned`
|
? `${resign.charAt(0).toUpperCase() + resign.slice(1)} resigned`
|
||||||
: 26 <= maxPoints ? 'Points' : 'Abandoned';
|
: 26 <= maxPoints ? 'Points' : 'Abandoned';
|
||||||
const shareUrl = `${window.location.origin}/battle/${game.uuid}`;
|
const canShare = !canContinue;
|
||||||
const canContinue = !resign && 26 > maxPoints;
|
const bothRegistered = game.bothRegistered;
|
||||||
|
const canContinue = bothRegistered && !resign && 26 > maxPoints;
|
||||||
const playUrl = `${window.location.origin}/play/${game.uuid}`;
|
const playUrl = `${window.location.origin}/play/${game.uuid}`;
|
||||||
|
const shareUrl = `${window.location.origin}/battle/${game.uuid}`;
|
||||||
|
|
||||||
const duration = formatDuration(game.created, game.date);
|
const duration = formatDuration(game.created, game.date);
|
||||||
const pointDiff = Math.abs((game.redPoints ?? 0) - (game.bluePoints ?? 0));
|
const pointDiff = Math.abs((game.redPoints ?? 0) - (game.bluePoints ?? 0));
|
||||||
@@ -108,7 +110,7 @@ export const BattleDialog = ({ games }) => {
|
|||||||
<i className="fa fa-play" />
|
<i className="fa fa-play" />
|
||||||
Continue
|
Continue
|
||||||
</a>
|
</a>
|
||||||
) : (
|
) : canShare ? (
|
||||||
<button
|
<button
|
||||||
className={`bd-share${copied ? ' bd-share--copied' : ''}`}
|
className={`bd-share${copied ? ' bd-share--copied' : ''}`}
|
||||||
onClick={handleShare}
|
onClick={handleShare}
|
||||||
@@ -118,7 +120,7 @@ export const BattleDialog = ({ games }) => {
|
|||||||
<i className={`fa ${copied ? 'fa-check' : 'fa-share-alt'}`} />
|
<i className={`fa ${copied ? 'fa-check' : 'fa-share-alt'}`} />
|
||||||
{copied ? 'Copied!' : 'Share'}
|
{copied ? 'Copied!' : 'Share'}
|
||||||
</button>
|
</button>
|
||||||
)}
|
) : null}
|
||||||
<button className="bd-close" onClick={() => setOpen(false)} aria-label="Close">
|
<button className="bd-close" onClick={() => setOpen(false)} aria-label="Close">
|
||||||
<i className="fa fa-times" />
|
<i className="fa fa-times" />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ final readonly class ProfileGameDto implements JsonSerializable
|
|||||||
public float $blueBonusPoints,
|
public float $blueBonusPoints,
|
||||||
public array $redBonusStats,
|
public array $redBonusStats,
|
||||||
public array $blueBonusStats,
|
public array $blueBonusStats,
|
||||||
|
public bool $bothRegistered,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ final readonly class ProfileGameDtoFactory
|
|||||||
redBonusPoints: $game->redBonusPoints ?? 0.0,
|
redBonusPoints: $game->redBonusPoints ?? 0.0,
|
||||||
blueBonusPoints: $game->blueBonusPoints ?? 0.0,
|
blueBonusPoints: $game->blueBonusPoints ?? 0.0,
|
||||||
redBonusStats: $game->redBonusStats ?? [],
|
redBonusStats: $game->redBonusStats ?? [],
|
||||||
blueBonusStats: $game->blueBonusStats ?? [],
|
blueBonusStats: $game->blueBonusStats ?? [],
|
||||||
|
bothRegistered: $game->red !== null && $game->blue !== null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,6 +129,7 @@ final readonly class ProfileGameDtoFactory
|
|||||||
blueBonusPoints: $battle->blueBonusPoints,
|
blueBonusPoints: $battle->blueBonusPoints,
|
||||||
redBonusStats: $battle->redBonusStats,
|
redBonusStats: $battle->redBonusStats,
|
||||||
blueBonusStats: $battle->blueBonusStats,
|
blueBonusStats: $battle->blueBonusStats,
|
||||||
|
bothRegistered: !$battle->oppIsGuest,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,19 @@ class RecentBattleRepository extends ServiceEntityRepository
|
|||||||
|
|
||||||
public function findRecentForUser(int $userId, int $limit = 30): array
|
public function findRecentForUser(int $userId, int $limit = 30): array
|
||||||
{
|
{
|
||||||
return $this->createQueryBuilder('rb')
|
$qb = $this->createQueryBuilder('rb');
|
||||||
->where('rb.userId = :uid')
|
|
||||||
|
return $qb
|
||||||
|
->where($qb->expr()->eq('rb.userId', ':uid'))
|
||||||
|
->andWhere(
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->eq('rb.oppIsGuest', ':false'),
|
||||||
|
$qb->expr()->isNotNull('rb.redPoints'),
|
||||||
|
$qb->expr()->isNotNull('rb.bluePoints')
|
||||||
|
),
|
||||||
|
)
|
||||||
->setParameter('uid', $userId)
|
->setParameter('uid', $userId)
|
||||||
|
->setParameter('false', false)
|
||||||
->orderBy('rb.updated', 'DESC')
|
->orderBy('rb.updated', 'DESC')
|
||||||
->setMaxResults($limit)
|
->setMaxResults($limit)
|
||||||
->getQuery()
|
->getQuery()
|
||||||
|
|||||||
Reference in New Issue
Block a user