@@ -34,12 +34,12 @@ class Seo extends Base {
3434 }
3535
3636 /**
37- * Stores the most recent route hash received from `onRouteChanged()`.
37+ * Stores the most recent route received from `onRouteChanged()`.
3838 * This is used to process a pending route update if the service becomes ready after a route change occurred.
39- * @member {String |null} #lastRouteHash=null
39+ * @member {Object |null} #lastRouteHash=null
4040 * @private
4141 */
42- #lastRouteHash = null
42+ #lastRoute = null
4343 /**
4444 * Caches the SEO metadata fetched from `apps/portal/resources/data/seo.json`.
4545 * This object maps route hash strings to their corresponding title and description.
@@ -57,8 +57,8 @@ class Seo extends Base {
5757 * @protected
5858 */
5959 afterSetIsReady ( value , oldValue ) {
60- if ( value && this . #lastRouteHash ) {
61- this . #updateDocumentHeadIfNeeded( this . #lastRouteHash )
60+ if ( value && this . #lastRoute ) {
61+ this . #updateDocumentHeadIfNeeded( this . #lastRoute )
6262 }
6363 }
6464
@@ -86,7 +86,7 @@ class Seo extends Base {
8686 if ( ! response . ok ) {
8787 throw new Error ( `HTTP error with status: ${ response . status } ` )
8888 }
89- this . #metadata = await response . json ( ) ;
89+ this . #metadata = await response . json ( )
9090 } catch ( error ) {
9191 console . error ( 'Error fetching SEO metadata:' , error )
9292 }
@@ -97,11 +97,13 @@ class Seo extends Base {
9797 * This method stores the new route hash and attempts to update the document head.
9898 * If the service is not yet ready (i.e., `initAsync` is still running), the update
9999 * is deferred until `isReady` becomes true.
100- * @param {String } hash The new route hash string.
100+ * @param {Object } config The configuration object.
101+ * @param {String } config.hash The new route hash string.
102+ * @param {String } config.windowId The windowId matching the route.
101103 */
102- onRouteChanged ( hash ) {
103- this . #lastRouteHash = hash ;
104- this . #updateDocumentHeadIfNeeded( hash )
104+ onRouteChanged ( config ) {
105+ this . #lastRoute = config ;
106+ this . #updateDocumentHeadIfNeeded( config )
105107 }
106108
107109 /**
@@ -111,12 +113,11 @@ class Seo extends Base {
111113 * @param {Object } config The configuration object containing `description` and `title`.
112114 * @param {String } config.description The new meta-description for the document.
113115 * @param {String } config.title The new title for the document.
116+ * @param {String } config.windowId The new title for the document.
114117 * @private
115118 */
116- async #updateDocumentHead( { description, title} ) {
117- let { windowId} = this ,
118- DocumentHead = await Neo . currentWorker . getAddon ( 'DocumentHead' , windowId ) ;
119-
119+ async #updateDocumentHead( { description, title, windowId} ) {
120+ let DocumentHead = await Neo . currentWorker . getAddon ( 'DocumentHead' , windowId ) ;
120121 await DocumentHead . update ( { description, title, windowId} )
121122 }
122123
@@ -126,18 +127,18 @@ class Seo extends Base {
126127 * and call `#updateDocumentHead`. If an update occurs, it clears `#lastRouteHash`.
127128 * This prevents multiple updates for the same route if `onRouteChanged` is called
128129 * before `initAsync` completes.
129- * @param {String } hash The route hash for which to update the document head.
130+ * @param {Object } config The route hash for which to update the document head.
130131 * @private
131132 */
132- #updateDocumentHeadIfNeeded( hash ) {
133+ #updateDocumentHeadIfNeeded( config ) {
133134 let me = this ;
134135
135136 if ( me . isReady ) {
136- let metadata = me . getMetadata ( hash ) ;
137+ let metadata = me . getMetadata ( config . hashString ) ;
137138
138139 if ( metadata ) {
139- me . #updateDocumentHead( metadata ) ;
140- me . #lastRouteHash = null
140+ me . #updateDocumentHead( { ... metadata , windowId : config . windowId } ) ;
141+ me . #lastRoute = null
141142 }
142143 }
143144 }
0 commit comments