Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231483

Change subject: Eliminate two API requests for board description fixed-html on 
load
......................................................................

Eliminate two API requests for board description fixed-html on load

contentChange was being emitted twice as part of the initialization
process (because populate() calls setContent()), and in response to
each event we sent an API request for the fixed-html of the board
description.

BoardDescriptionWidget takes pains to reuse the description HTML
from the initial DOM, so it shouldn't then refetch that HTML
from the server (twice).

Change-Id: Ifa569aba9151db7ef849f6f2cda5fefeadccef21
---
M modules/flow/dm/mw.flow.dm.RevisionedContent.js
1 file changed, 8 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/83/231483/1

diff --git a/modules/flow/dm/mw.flow.dm.RevisionedContent.js 
b/modules/flow/dm/mw.flow.dm.RevisionedContent.js
index 6f06aeb..e350ead 100644
--- a/modules/flow/dm/mw.flow.dm.RevisionedContent.js
+++ b/modules/flow/dm/mw.flow.dm.RevisionedContent.js
@@ -191,9 +191,12 @@
         * @fires contentChange
         */
        mw.flow.dm.RevisionedContent.prototype.setContent = function ( content 
) {
+               var wasUnset = this.content === null;
                if ( content !== undefined && this.content !== content ) {
                        this.content = content;
-                       this.emit( 'contentChange', this.content, 
this.contentFormat );
+                       if ( !wasUnset ) {
+                               this.emit( 'contentChange', this.content, 
this.contentFormat );
+                       }
                }
        };
 
@@ -217,9 +220,12 @@
         * @param {string} contentFormat Content format
         */
        mw.flow.dm.RevisionedContent.prototype.setContentFormat = function ( 
contentFormat ) {
+               var wasUnset = this.contentFormat === null;
                if ( contentFormat !== undefined && this.contentFormat !== 
contentFormat ) {
                        this.contentFormat = contentFormat;
-                       this.emit( 'contentChange', this.content, 
this.contentFormat );
+                       if ( !wasUnset ) {
+                               this.emit( 'contentChange', this.content, 
this.contentFormat );
+                       }
                }
        };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/231483
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa569aba9151db7ef849f6f2cda5fefeadccef21
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to