From 93beb6d25e037b32beb5d50800fa36b69fe80c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Wed, 22 Feb 2023 20:17:51 +0100 Subject: [PATCH] hack CardDeck to honor reload when string is returned from UA execute --- src/CardDeck.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/CardDeck.php b/src/CardDeck.php index 49f289b48b..5733416fd6 100644 --- a/src/CardDeck.php +++ b/src/CardDeck.php @@ -223,6 +223,11 @@ protected function initActionExecutor(Model\UserAction $action): ExecutorInterfa protected function jsExecute($return, Model\UserAction $action): JsBlock { if (is_string($return)) { + // hack to test reload with read only demos + if (str_ends_with($return, 'was executed. In demo mode all changes are reverved.')) { + return $this->jsModelReturn($action, $return); + } + return $this->jsCreateNotifier($action, $return); } elseif ($return instanceof JsExpressionable) { return new JsBlock([$return]); @@ -259,7 +264,7 @@ protected function jsModelReturn(Model\UserAction $action, string $msg = 'Done!' { $res = new JsBlock(); $res->addStatement($this->jsCreateNotifier($action, $msg)); - $card = $action->getEntity()->isLoaded() ? $this->findCard($action->getEntity()) : null; + $card = $action->isOwnerEntity() && $action->getEntity()->isLoaded() ? $this->findCard($action->getEntity()) : null; if ($card !== null) { $res->addStatement($card->jsReload($this->getReloadArgs())); } else {