Add Replay button to show a donation alert again
Test and Release / test (push) Successful in 6m43s
Test and Release / release (push) Successful in 24s

Donations > Replay queues the alert for the open alerts overlay. Requests
expire after 60 seconds, play once, and never re-apply totals, timers,
counters, rewards or tiers. Held, rejected and pending donations are excluded.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-27 21:21:19 -08:00
1 parent 96bae1cbf9
commit 971a4ac482
12 files changed
+258 -10

No files matched your search

+17 -7
View File
@@ -53,15 +53,20 @@ final class OverlayService {
} else {
$rows = $this->source->donations( $since, 20 );
}
$ids = array_values( array_filter( array_map( static fn( $r ) => (int) ( $r['id'] ?? 0 ), $rows ) ) );
// Replays travel beside the normal feed and may point at donations older than the recent window.
$requests = ( $recent && $this->source instanceof ReplaySource ) ? $this->source->pendingReplays( $now ) : array();
$replayRows = $requests ? $this->source->donationsByIds( array_column( $requests, 'id' ) ) : array();
$ids = array_values( array_unique( array_filter( array_map( static fn( $r ) => (int) ( $r['id'] ?? 0 ), array_merge( $rows, $replayRows ) ) ) ) );
$bonuses = ( ( $recent || null !== $since ) && $ids ) ? $this->source->bonusesFor( $ids ) : array();
$actions = ( ( $recent || null !== $since ) && $ids && $this->source instanceof ActionsSource ) ? $this->source->actionsFor( $ids ) : array();
$tiers = ( ( $recent || null !== $since ) && $ids && $this->source instanceof TiersSource ) ? $this->source->tiersReachedFor( $ids ) : array();
foreach ( $rows as $i => $r ) {
$rows[ $i ]['bonuses'] = $bonuses[ (int) ( $r['id'] ?? 0 ) ] ?? array();
$rows[ $i ]['actions'] = $actions[ (int) ( $r['id'] ?? 0 ) ] ?? array();
$rows[ $i ]['tiers'] = $tiers[ (int) ( $r['id'] ?? 0 ) ] ?? array();
}
$decorate = static fn( array $r ): array => array(
'bonuses' => $bonuses[ (int) ( $r['id'] ?? 0 ) ] ?? array(),
'actions' => $actions[ (int) ( $r['id'] ?? 0 ) ] ?? array(),
'tiers' => $tiers[ (int) ( $r['id'] ?? 0 ) ] ?? array(),
) + $r;
$rows = array_map( $decorate, $rows );
$replayRows = array_map( $decorate, $replayRows );
$mediaFor = null;
$defs = ( $recent || null !== $since ) ? $this->defs() : array();
if ( $defs && $ids && $this->source instanceof AlertMediaSource ) {
@@ -71,7 +76,12 @@ final class OverlayService {
$r, $name, $amount, $defs, $triggered[ (int) ( $r['id'] ?? 0 ) ] ?? array(), static fn( int $id ): ?array => $src->attachment( $id )
);
}
return Payloads::alerts( $rows, $since, $recent ? 20 : 10, $recent, $mediaFor );
$out = Payloads::alerts( $rows, $since, $recent ? 20 : 10, $recent, $mediaFor );
$replays = Payloads::replays( $replayRows, $requests, $mediaFor );
if ( $replays ) {
$out['replays'] = $replays;
}
return $out;
case 'actions':
$rows = ( $gid && $this->source instanceof ActionsSource ) ? $this->source->menuActions( $gid ) : array();
return Payloads::actionsMenu( $goal, $rows );