From afcac54cfd7d8c730b66842f822a5ee1c1005747 Mon Sep 17 00:00:00 2001 From: Christian Hartmann Date: Fri, 30 Aug 2024 18:14:23 +0200 Subject: [PATCH] try to avoid using hash in API calls for internal links Signed-off-by: Christian Hartmann --- lib/Controller/PageController.php | 9 ++++++--- src/Forms.vue | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 2c425d705..a66e8f3ba 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -79,13 +79,16 @@ public function __construct( * * @return TemplateResponse */ - public function index(): TemplateResponse { + public function index(?string $hash = null): TemplateResponse { Util::addScript($this->appName, 'forms-main'); Util::addStyle($this->appName, 'forms'); Util::addStyle($this->appName, 'forms-style'); $this->insertHeaderOnIos(); $this->initialState->provideInitialState('maxStringLengths', Constants::MAX_STRING_LENGTHS); $this->initialState->provideInitialState('appConfig', $this->configService->getAppConfig()); + if (isset($hash)) { + $this->initialState->provideInitialState('formId', $this->formMapper->findByHash($hash)->id); + } return new TemplateResponse($this->appName, self::TEMPLATE_MAIN, [ 'id-app-content' => '#app-content-vue', 'id-app-navigation' => '#app-navigation-vue', @@ -98,8 +101,8 @@ public function index(): TemplateResponse { * * @return TemplateResponse */ - public function views(): TemplateResponse { - return $this->index(); + public function views(string $hash): TemplateResponse { + return $this->index($hash); } /** diff --git a/src/Forms.vue b/src/Forms.vue index 25ae6b073..66411b4a1 100644 --- a/src/Forms.vue +++ b/src/Forms.vue @@ -413,8 +413,8 @@ export default { ) { try { const response = await axios.get( - generateOcsUrl('apps/forms/api/v3/forms/0?hash={hash}', { - hash, + generateOcsUrl('apps/forms/api/v3/forms/{id}', { + id: loadState(appName, 'formId'), }), ) const form = OcsResponse2Data(response)