Pause instead of dangling when the live slide is deleted
CI / Deploy / test (push) Successful in 55s
CI / Deploy / deploy (push) Skipped

Deleting the live slide set current_slide_id directly, so participants saw
"not started", and deleting the paused slide left paused_slide_id pointing
to a slide that no longer exists. Poll::forgetSlide() now pauses and resumes
with the slide taking its place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-08 22:02:58 +01:00
1 parent 8b0e82d806
commit a7f9783a75
4 files changed
+75 -7

No files matched your search

+15 -5
View File
@@ -105,12 +105,22 @@ class SlidesController extends AdminAppController
{
$this->request->allowMethod(['post']);
$slide = $this->loadSlide($id);
if ($this->poll->current_slide_id === $slide->id) {
$this->poll->current_slide_id = null;
// Deleting the live (or paused) slide pauses the poll; → resumes with the slide taking its place.
$ids = $this->Slides->find()
->select(['id'])
->where(['poll_id' => $this->poll->id])
->orderBy(['position' => 'ASC', 'id' => 'ASC'])
->all()
->extract('id')
->toList();
$index = (int)array_search($slide->id, $ids, true);
$this->poll->forgetSlide($slide->id, $ids[$index + 1] ?? $ids[$index - 1] ?? null);
$this->Slides->getConnection()->transactional(function () use ($slide): void {
$this->Polls->saveOrFail($this->poll);
}
$this->Slides->deleteOrFail($slide);
$this->Slides->normalizePositions($this->poll->id);
$this->Slides->deleteOrFail($slide);
$this->Slides->normalizePositions($this->poll->id);
});
$this->Flash->success(__('Folie gelöscht.'));
return $this->redirect($this->adminUrl());
+18
View File
@@ -99,6 +99,24 @@ class Poll extends Entity
$this->embed_seen_at = null;
}
/**
* A slide is being deleted. If it was live or is the one a pause resumes, the poll pauses
* and resumes with $resumeSlideId instead (null: no slides left = not started). Idempotent.
*
* @param int $slideId Deleted slide
* @param int|null $resumeSlideId Slide that takes its place (must belong to this poll)
* @return void
*/
public function forgetSlide(int $slideId, ?int $resumeSlideId): void
{
if ($this->current_slide_id !== $slideId && $this->paused_slide_id !== $slideId) {
return;
}
$this->current_slide_id = null;
$this->paused_slide_id = $resumeSlideId;
$this->embed_seen_at = null;
}
/**
* @return bool Paused after a slide had been live (not: not started yet)
*/