Merge "Fix summary when topic title is changed after restoring from autosave"

This commit is contained in:
jenkins-bot 2023-02-02 17:56:41 +00:00 committed by Gerrit Code Review
commit b30256d01b
3 changed files with 27 additions and 6 deletions

View file

@ -351,6 +351,12 @@ CommentController.prototype.setupReplyWidget = function ( replyWidget, data, sup
this.replyWidget = replyWidget;
};
CommentController.prototype.storeEditSummary = function () {
if ( this.replyWidget ) {
this.replyWidget.storage.set( this.replyWidget.storagePrefix + '/summary', this.replyWidget.getEditSummary() );
}
};
/**
* Focus the first input field inside the controller.
*/

View file

@ -137,6 +137,12 @@ NewTopicController.prototype.setupReplyWidget = function ( replyWidget ) {
// TODO This should happen immediately rather than waiting for the reply widget to load,
// then we wouldn't need this check, but the autosave code is in ReplyWidget.
this.sectionTitle.setValue( title );
this.prevTitleText = title;
if ( this.replyWidget.storage.get( this.replyWidget.storagePrefix + '/summary' ) === null ) {
var generatedSummary = this.generateSummary( title );
this.replyWidget.editSummaryInput.setValue( generatedSummary );
}
}
if ( this.replyWidget.modeTabSelect ) {
@ -234,6 +240,20 @@ NewTopicController.prototype.clearStorage = function () {
}
};
NewTopicController.prototype.storeEditSummary = function () {
if ( this.replyWidget ) {
var currentSummary = this.replyWidget.editSummaryInput.getValue();
var generatedSummary = this.generateSummary( this.sectionTitle.getValue() );
if ( currentSummary === generatedSummary ) {
// Do not store generated summaries (T315730)
this.replyWidget.storage.remove( this.replyWidget.storagePrefix + '/summary' );
return;
}
}
NewTopicController.super.prototype.storeEditSummary.call( this );
};
/**
* @inheritdoc
*/

View file

@ -493,16 +493,11 @@ ReplyWidget.prototype.toggleAdvanced = function ( showAdvanced ) {
this.advanced.toggle( !!this.showAdvanced );
this.advancedToggle.setIndicator( this.showAdvanced ? 'up' : 'down' );
this.storeEditSummary();
this.storage.set( this.storagePrefix + '/showAdvanced', this.showAdvanced ? '1' : '' );
};
ReplyWidget.prototype.onEditSummaryChange = function () {
this.storeEditSummary();
};
ReplyWidget.prototype.storeEditSummary = function () {
this.storage.set( this.storagePrefix + '/summary', this.getEditSummary() );
this.commentController.storeEditSummary();
};
ReplyWidget.prototype.getEditSummary = function () {