From 68dc46ad0f43fb1e655381fa14504959a2d6fe33 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Tue, 14 Jul 2026 00:16:16 +0530 Subject: docs: add JSDoc comments to form-caching module --- src/scripts/common/login/form-caching.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/scripts/common/login/form-caching.ts b/src/scripts/common/login/form-caching.ts index bde6442..508d076 100644 --- a/src/scripts/common/login/form-caching.ts +++ b/src/scripts/common/login/form-caching.ts @@ -1,7 +1,12 @@ import { addPostListener, addPostResponder, JQueryAjaxResponse } from "@/shared/intercept-jquery-ajax"; +/** Caches the login area HTML to avoid re-fetching it on subsequent requests. */ let loginAreaHTML: string | null = null; +/** + * Intercepts `viewLoginAreaAction` AJAX requests and serves the cached HTML + * if available, avoiding an unnecessary network round-trip. + */ addPostResponder( "viewLoginAreaAction", function(_args): JQueryAjaxResponse | undefined | null { @@ -13,10 +18,14 @@ addPostResponder( } ); +/** + * Listens for successful `viewLoginAreaAction` responses and stores the + * returned HTML so the responder above can serve it from cache later. + */ addPostListener( "viewLoginAreaAction", function(_args, result): void { - loginAreaHTML = result.data?.toString() ?? ""; + loginAreaHTML = result.data?.toString() ?? null; }, false ); -- cgit v1.2.3