Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 221cf0f

Browse files
committed
fix(challenge): Update diff and header when a new query is submitted
1 parent b0af254 commit 221cf0f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Twig/Components/Challenge/Header.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@
1111
use App\Repository\SolutionEventRepository;
1212
use App\Service\PassRateService;
1313
use App\Service\Types\PassRate;
14-
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent;
14+
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
15+
use Symfony\UX\LiveComponent\Attribute\LiveListener;
16+
use Symfony\UX\LiveComponent\Attribute\LiveProp;
17+
use Symfony\UX\LiveComponent\DefaultActionTrait;
1518

16-
#[AsTwigComponent]
19+
#[AsLiveComponent]
1720
final class Header
1821
{
22+
use DefaultActionTrait;
23+
24+
#[LiveProp]
1925
public User $user;
26+
27+
#[LiveProp]
2028
public Question $question;
21-
public int $limit;
2229

2330
public function __construct(
2431
private readonly SolutionEventRepository $solutionEventRepository,
@@ -50,4 +57,10 @@ public function getPassRate(): PassRate
5057
{
5158
return $this->passRateService->getPassRate($this->question, $this->user->getGroup());
5259
}
60+
61+
#[LiveListener('app:challenge-executor:query-created')]
62+
public function onQueryUpdated(): void
63+
{
64+
// Update "Solve State" and "Pass Rate" after a new query is created.
65+
}
5366
}

src/Twig/Components/Challenge/Tabs/DiffPresenter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\Serializer\SerializerInterface;
1515
use Symfony\Contracts\Translation\TranslatorInterface;
1616
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
17+
use Symfony\UX\LiveComponent\Attribute\LiveArg;
18+
use Symfony\UX\LiveComponent\Attribute\LiveListener;
1719
use Symfony\UX\LiveComponent\Attribute\LiveProp;
1820
use Symfony\UX\LiveComponent\DefaultActionTrait;
1921
use Symfony\UX\TwigComponent\Attribute\PostMount;
@@ -116,4 +118,10 @@ public function getDiff(): ?string
116118

117119
return $result;
118120
}
121+
122+
#[LiveListener('app:challenge-executor:query-created')]
123+
public function onQueryUpdated(#[LiveArg] string $query): void
124+
{
125+
$this->query = $query;
126+
}
119127
}

0 commit comments

Comments
 (0)