mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +00:00
Fix showing temp user popup after page reload
Bug: T344879 Change-Id: I1bb86468c27d4fbbd55ebcdc81ec841fbfeeb952
This commit is contained in:
parent
44f652aa82
commit
c0f5a95504
|
@ -465,6 +465,7 @@ CommentController.prototype.save = function ( pageName ) {
|
|||
data.returnto = pageName;
|
||||
var params = new URLSearchParams();
|
||||
params.set( 'dtrepliedto', commentController.getThreadItem().id );
|
||||
params.set( 'dttempusercreated', '1' );
|
||||
data.returntoquery = params.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -288,6 +288,7 @@ function getReplyWidgetModules( visual ) {
|
|||
* @param {jQuery} $container Page container
|
||||
* @param {Object<string,Mixed>} [state] Page state data object
|
||||
* @param {string} [state.repliedTo] The comment ID that was just replied to
|
||||
* @param {boolean} [state.tempUserCreated] Whether a temp user was just created
|
||||
*/
|
||||
function init( $container, state ) {
|
||||
var
|
||||
|
@ -516,10 +517,12 @@ function init( $container, state ) {
|
|||
|
||||
if ( state.repliedTo === utils.NEW_TOPIC_COMMENT_ID ) {
|
||||
mw.hook( 'postEdit' ).fire( {
|
||||
tempUserCreated: state.tempUserCreated,
|
||||
message: mw.msg( 'discussiontools-postedit-confirmation-topicadded', mw.user )
|
||||
} );
|
||||
} else {
|
||||
mw.hook( 'postEdit' ).fire( {
|
||||
tempUserCreated: state.tempUserCreated,
|
||||
message: mw.msg( 'discussiontools-postedit-confirmation-published', mw.user )
|
||||
} );
|
||||
}
|
||||
|
@ -686,7 +689,10 @@ function update( data, threadItem, pageName, replyWidget ) {
|
|||
replyWidget.unbindBeforeUnloadHandler();
|
||||
replyWidget.clearStorage();
|
||||
replyWidget.setPending( true );
|
||||
window.location = data.tempusercreatedredirect || mw.util.getUrl( pageName, { dtrepliedto: threadItem.id } );
|
||||
window.location = data.tempusercreatedredirect || mw.util.getUrl( pageName, {
|
||||
dtrepliedto: threadItem.id,
|
||||
dttempusercreated: '1'
|
||||
} );
|
||||
logSaveSuccess();
|
||||
return;
|
||||
}
|
||||
|
@ -696,6 +702,7 @@ function update( data, threadItem, pageName, replyWidget ) {
|
|||
|
||||
// Highlight the new reply after re-initializing
|
||||
mw.dt.initState.repliedTo = threadItem.id;
|
||||
mw.dt.initState.tempUserCreated = data.tempusercreated;
|
||||
|
||||
// Update page state
|
||||
var pageUpdated = $.Deferred();
|
||||
|
|
|
@ -22,8 +22,10 @@ if ( url.searchParams.get( 'dtrepliedto' ) ) {
|
|||
// If we had to reload the page to highlight the new comment, extract that data from the URL and
|
||||
// clean it up.
|
||||
mw.dt.initState.repliedTo = url.searchParams.get( 'dtrepliedto' );
|
||||
mw.dt.initState.tempUserCreated = url.searchParams.has( 'dttempusercreated' );
|
||||
if ( window.history.replaceState ) {
|
||||
url.searchParams.delete( 'dtrepliedto' );
|
||||
url.searchParams.delete( 'dttempusercreated' );
|
||||
window.history.replaceState( {}, '', url );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue