mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Fix summary when topic title is changed after restoring from autosave
Previously, we would restore the title and the summary generated from it, but we wouldn't restore `prevTitleText`, so we would lose track of the fact that it was automatically generated, and stop updating it because of that. Instead of adding it to the stored data, let's instead stop storing automatically generated summaries, and tweak the code to support generating them when restoring. Bug: T315730 Change-Id: I96420bc0a3e34373190d2c2c0db2e2175ad3156d
This commit is contained in:
parent
87d67d4a1c
commit
1fb67ef63d
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -126,6 +126,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 ) {
|
||||
|
@ -223,6 +229,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