Merge "Clear autosave when following links from the legacy hint"

This commit is contained in:
jenkins-bot 2022-01-31 20:16:21 +00:00 committed by Gerrit Code Review
commit 1fdefedc69

View file

@ -134,6 +134,7 @@ NewTopicController.prototype.setupReplyWidget = function ( replyWidget, data ) {
* Create and display a hint dialog that redirects users to the non-DT version of this tool * Create and display a hint dialog that redirects users to the non-DT version of this tool
*/ */
NewTopicController.prototype.setupTopicHint = function () { NewTopicController.prototype.setupTopicHint = function () {
var topicController = this;
var legacyURI; var legacyURI;
try { try {
legacyURI = new mw.Uri(); legacyURI = new mw.Uri();
@ -158,6 +159,14 @@ NewTopicController.prototype.setupTopicHint = function () {
title: mw.msg( 'discussiontools-newtopic-legacy-hint-close' ) title: mw.msg( 'discussiontools-newtopic-legacy-hint-close' )
} ).connect( this, { click: 'onTopicHintCloseClick' } ); } ).connect( this, { click: 'onTopicHintCloseClick' } );
this.topicHint.$element.prepend( dismissButton.$element ); this.topicHint.$element.prepend( dismissButton.$element );
this.topicHint.$element.find( 'a' ).on( 'click', function () {
// Clicking to follow this link should immediately discard the
// autosave. We can do this before the onBeforeUnload handler asks
// them to confirm, because if they decide to cancel the navigation
// then the autosave will occur again.
topicController.clearStorage();
topicController.replyWidget.clearStorage();
} );
this.container.$element.before( this.topicHint.$element ); this.container.$element.before( this.topicHint.$element );
this.topicHint.toggle( true ); this.topicHint.toggle( true );