mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-12 01:16:19 +00:00
Don't show auto-save notifications when dynamically updating the page
Bug: T302327 Depends-On: If94e603458a385ba6eb15c4e29144f72e3ad12ca Change-Id: I28f965137b986d00ac7a020ca93d8dc5195f5d4f
This commit is contained in:
parent
da49448f43
commit
d619308098
|
@ -124,8 +124,9 @@ CommentController.static.initType = 'page';
|
|||
*
|
||||
* @param {string} [mode] Optionally force a mode, 'visual' or 'source'
|
||||
* @param {boolean} [hideErrors] Suppress errors, e.g. when restoring auto-save
|
||||
* @param {boolean} [suppressNotifications] Don't notify the user if recovering auto-save
|
||||
*/
|
||||
CommentController.prototype.setup = function ( mode, hideErrors ) {
|
||||
CommentController.prototype.setup = function ( mode, hideErrors, suppressNotifications ) {
|
||||
var threadItem = this.getThreadItem(),
|
||||
commentController = this;
|
||||
|
||||
|
@ -204,7 +205,7 @@ CommentController.prototype.setup = function ( mode, hideErrors ) {
|
|||
}
|
||||
$( commentController.newListItem ).empty().append( replyWidget.$element );
|
||||
|
||||
commentController.setupReplyWidget( replyWidget );
|
||||
commentController.setupReplyWidget( replyWidget, {}, suppressNotifications );
|
||||
|
||||
commentController.showAndFocus();
|
||||
|
||||
|
@ -306,13 +307,13 @@ CommentController.prototype.createReplyWidget = function ( commentDetails, confi
|
|||
} );
|
||||
};
|
||||
|
||||
CommentController.prototype.setupReplyWidget = function ( replyWidget, data ) {
|
||||
CommentController.prototype.setupReplyWidget = function ( replyWidget, data, suppressNotifications ) {
|
||||
replyWidget.connect( this, {
|
||||
teardown: 'teardown',
|
||||
reloadPage: this.emit.bind( this, 'reloadPage' )
|
||||
} );
|
||||
|
||||
replyWidget.setup( data );
|
||||
replyWidget.setup( data, suppressNotifications );
|
||||
replyWidget.updateNewCommentsWarning( this.newComments );
|
||||
|
||||
this.replyWidget = replyWidget;
|
||||
|
|
|
@ -104,8 +104,8 @@ NewTopicController.prototype.setup = function ( mode ) {
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
NewTopicController.prototype.setupReplyWidget = function ( replyWidget, data ) {
|
||||
NewTopicController.super.prototype.setupReplyWidget.call( this, replyWidget, data );
|
||||
NewTopicController.prototype.setupReplyWidget = function ( replyWidget ) {
|
||||
NewTopicController.super.prototype.setupReplyWidget.apply( this, arguments );
|
||||
|
||||
this.$notices.empty();
|
||||
for ( var noticeName in this.replyWidget.commentDetails.notices ) {
|
||||
|
|
|
@ -259,8 +259,9 @@ function init( $container, state ) {
|
|||
* @param {jQuery} $link Add section link for new topic controller
|
||||
* @param {string} [mode] Optionally force a mode, 'visual' or 'source'
|
||||
* @param {boolean} [hideErrors] Suppress errors, e.g. when restoring auto-save
|
||||
* @param {boolean} [suppressNotifications] Don't notify the user if recovering auto-save
|
||||
*/
|
||||
function setupController( commentId, $link, mode, hideErrors ) {
|
||||
function setupController( commentId, $link, mode, hideErrors, suppressNotifications ) {
|
||||
var commentController, $addSectionLink;
|
||||
|
||||
if ( commentId === utils.NEW_TOPIC_COMMENT_ID ) {
|
||||
|
@ -298,7 +299,7 @@ function init( $container, state ) {
|
|||
} );
|
||||
} );
|
||||
|
||||
commentController.setup( mode, hideErrors );
|
||||
commentController.setup( mode, hideErrors, suppressNotifications );
|
||||
if ( lastControllerScrollOffset ) {
|
||||
$( document.documentElement ).scrollTop(
|
||||
$( document.documentElement ).scrollTop() +
|
||||
|
@ -347,13 +348,13 @@ function init( $container, state ) {
|
|||
if ( storage.get( 'reply/' + comment.id + '/saveable' ) ) {
|
||||
mode = storage.get( 'reply/' + comment.id + '/mode' );
|
||||
$link = $( commentNodes[ i ] );
|
||||
setupController( comment.id, $link, mode, true );
|
||||
setupController( comment.id, $link, mode, true, !state.firstLoad );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( storage.get( 'reply/' + utils.NEW_TOPIC_COMMENT_ID + '/saveable' ) ) {
|
||||
mode = storage.get( 'reply/' + utils.NEW_TOPIC_COMMENT_ID + '/mode' );
|
||||
setupController( utils.NEW_TOPIC_COMMENT_ID, $( [] ), mode, true );
|
||||
setupController( utils.NEW_TOPIC_COMMENT_ID, $( [] ), mode, true, !state.firstLoad );
|
||||
} else if ( mw.config.get( 'wgDiscussionToolsStartNewTopicTool' ) ) {
|
||||
setupController( utils.NEW_TOPIC_COMMENT_ID, $( [] ) );
|
||||
}
|
||||
|
|
|
@ -7,7 +7,9 @@ var controller = require( './controller.js' ),
|
|||
*/
|
||||
mw.dt = {};
|
||||
|
||||
mw.dt.initState = {};
|
||||
mw.dt.initState = {
|
||||
firstLoad: true
|
||||
};
|
||||
|
||||
// New Topic A/B test for logged out users:
|
||||
var tokenData = mw.storage.getObject( 'DTNewTopicABToken' );
|
||||
|
|
|
@ -89,7 +89,7 @@ ReplyWidgetVisual.prototype.getMode = function () {
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ReplyWidgetVisual.prototype.setup = function ( data ) {
|
||||
ReplyWidgetVisual.prototype.setup = function ( data, suppressNotifications ) {
|
||||
var widget = this,
|
||||
target = this.replyBodyWidget.target;
|
||||
|
||||
|
@ -116,7 +116,7 @@ ReplyWidgetVisual.prototype.setup = function ( data ) {
|
|||
} );
|
||||
|
||||
target.getSurface().getModel().setAutosaveDocId( widget.storagePrefix );
|
||||
target.initAutosave();
|
||||
target.initAutosave( suppressNotifications );
|
||||
widget.afterSetup();
|
||||
|
||||
// This needs to bind after surfaceReady so any initial population doesn't trigger it early:
|
||||
|
|
Loading…
Reference in a new issue