Pause instead of dangling when the live slide is deleted
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:
1 parent
8b0e82d806
commit
a7f9783a75
4 files changed
+75
-7
No files matched your search
@@ -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());
|
||||
|
||||
Reference in new issue
Block a user