mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +00:00
Merge "Fix summary when topic title is changed after restoring from autosave"
This commit is contained in:
commit
b30256d01b
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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 () {
|
||||
|
|
Loading…
Reference in a new issue