From 6021957a0bfa0c16bfe933083888e967914dbd7b Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 20 Aug 2026 14:15:29 +0200 Subject: [PATCH] refactor: load elements through core's shared element repository MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build the page's element set via Alchemy::PageVersion#element_repository instead of instantiating Alchemy::ElementsRepository directly. This routes json_api through the same element-loading seam the rest of the Alchemy ecosystem uses, so it inherits core's behaviour automatically — the repository memoization today, and a shared element preloader once core provides one — rather than maintaining a parallel construction here. The change is behaviour-preserving: element_repository still wraps the version's (eager-loaded) elements and applies the same visible filter. (cherry picked from commit 1f1cce454d839b3ab74ee8ce06cef9435db528ec) --- app/models/alchemy/json_api/page.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/alchemy/json_api/page.rb b/app/models/alchemy/json_api/page.rb index ae3bd232..f3d17780 100644 --- a/app/models/alchemy/json_api/page.rb +++ b/app/models/alchemy/json_api/page.rb @@ -45,7 +45,7 @@ def ancestor_ids def element_repository return Alchemy::ElementsRepository.none unless page_version - Alchemy::ElementsRepository.new(page_version.elements).visible + page_version.element_repository.visible end end end