Merge "Warn when target comments in a link can't be found"

This commit is contained in:
jenkins-bot 2022-02-28 23:24:15 +00:00 committed by Gerrit Code Review
commit 0dc293fc20
4 changed files with 43 additions and 0 deletions

View file

@ -121,6 +121,8 @@
"discussiontools-replylink",
"discussiontools-replywidget-loading",
"discussiontools-replywidget-watchthis",
"discussiontools-target-comment-missing",
"discussiontools-target-comments-missing",
"discussiontools-topicsubscription-button-subscribe",
"discussiontools-topicsubscription-button-subscribe-tooltip",
"discussiontools-topicsubscription-button-unsubscribe",

View file

@ -99,6 +99,8 @@
"discussiontools-replywidget-transcluded": "Your comment will be saved at [[$1]].",
"discussiontools-replywidget-watchthis": "Add this page to your [[Special:Watchlist|watchlist]]",
"discussiontools-signature-prefix": " ",
"discussiontools-target-comment-missing": "This comment could not be found. It might have been deleted or moved.",
"discussiontools-target-comments-missing": "New comments could not be found. They might have been deleted or moved.",
"discussiontools-topicsubscription-action-unsubscribe-button": "Unsubscribe",
"discussiontools-topicsubscription-action-unsubscribe-prompt": "Unsubscribe from this topic?",
"discussiontools-topicsubscription-button-subscribe": "subscribe",

View file

@ -110,6 +110,8 @@
"discussiontools-replywidget-transcluded": "Message explaining that the comment will be saved on a different page than the one you're viewing right now (because it was transcluded from it). Parameter: $1 page name",
"discussiontools-replywidget-watchthis": "Label for a checkbox in the reply widget. It is used instead of the usual {{msg-mw|watchthis}} to distinguish the watchlist functionality from [[mw:Talk_pages_project/Feature_summary#Topic_subscriptions|topic subscriptions]].\n{{Identical|Add this page to your watchlist}}",
"discussiontools-signature-prefix": "{{optional}}\nWikitext that prefixes the signature. The prefix and signature will be appended directly to the message, so this must include a leading space if a gap is desired.\n\nThis message intentionally doesn't use the prefix from {{msg-mw|sig-text}}, because it is not actually commonly used on many wikis, but you can include it in the translation if that is the convention in your language.\n{{Format|plain}}",
"discussiontools-target-comment-missing": "Message shown in a popup when the user follows a link that would highlight a '''single''' comment on a talk page, e.g. [https://en.wikipedia.org/wiki/User_talk:Example#c-Example1-2019-06-26T08:00:00.000Z-Example_discussion_title], but the comment doesn't exist on the page any more. Such links are used in notifications, or can be used in comments by other users.\n\nSee also for multiple comments: {{msg-mw|discussiontools-target-comments-missing}}",
"discussiontools-target-comments-missing": "Message shown in a popup when the user follows a link that would highlight potentially '''multiple new''' comments on a talk page, but the exact number is unknown, e.g. [https://en.wikipedia.org/w/index.php?title=User_talk:Example&dtnewcommentssince=c-Example1-2019-06-26T10:20:00.000Z-Example2-2019-06-26T10:10:00.000Z], but none of these comments exist on the page any more. Such links are generated by notifications.\n\nSee also for a single comments: {{msg-mw|discussiontools-target-comment-missing}}",
"discussiontools-topicsubscription-action-unsubscribe-button": "Button to unsubscribe from a topic.\n{{identical|Unsubscribe}}",
"discussiontools-topicsubscription-action-unsubscribe-prompt": "Prompt shown when about to unsubscribe from a topic on an action page.",
"discussiontools-topicsubscription-button-subscribe": "Label for the subscribe link added to each section. Use the same casing as section edit links.\n\nAppears in the same area as:\n* {{msg-mw|editsection}}\n* {{msg-mw|visualeditor-ca-editsource-section}}\n* {{msg-mw|discussiontools-topicsubscription-button-unsubscribe}}\n* {{msg-mw|discussiontools-replylink}}",

View file

@ -513,6 +513,7 @@ function updateSubscriptionStates( $container, headingsToUpdate ) {
}
var $highlightedTarget = null;
var missingTargetNotifPromise = null;
/**
* Highlight the comment(s) on the page associated with the URL hash or query string
*
@ -527,6 +528,12 @@ function highlightTargetComment( threadItemSet, noScroll ) {
$highlightedTarget.remove();
$highlightedTarget = null;
}
if ( missingTargetNotifPromise ) {
missingTargetNotifPromise.then( function ( notif ) {
notif.close();
} );
missingTargetNotifPromise = null;
}
// eslint-disable-next-line no-jquery/no-global-selector
var targetElement = $( ':target' )[ 0 ];
@ -538,6 +545,15 @@ function highlightTargetComment( threadItemSet, noScroll ) {
return;
}
if ( location.hash.match( /^#c-/ ) && !targetElement ) {
missingTargetNotifPromise = mw.loader.using( 'mediawiki.notification' ).then( function () {
return mw.notification.notify(
mw.message( 'discussiontools-target-comment-missing' ).parse(),
{ type: 'warn', autoHide: false }
);
} );
}
var uri;
try {
uri = new mw.Uri( location.href );
@ -567,6 +583,9 @@ function highlightTargetComment( threadItemSet, noScroll ) {
function highlightNewComments( threadItemSet, noScroll, newCommentIds, newCommentsSinceId, inThread ) {
newCommentIds = newCommentIds || [];
var highlightsRequested = newCommentIds.length || newCommentsSinceId;
var highlightsRequestedSingle = !newCommentsSinceId && newCommentIds.length === 1;
if ( newCommentsSinceId ) {
var newCommentsSince = threadItemSet.findCommentById( newCommentsSinceId );
if ( newCommentsSince && newCommentsSince instanceof CommentItem ) {
@ -615,6 +634,17 @@ function highlightNewComments( threadItemSet, noScroll, newCommentIds, newCommen
}
document.getElementById( comments[ topmostComment ].id ).scrollIntoView();
}
} else if ( highlightsRequested ) {
missingTargetNotifPromise = mw.loader.using( 'mediawiki.notification' ).then( function () {
return mw.notification.notify(
mw.message(
highlightsRequestedSingle ?
'discussiontools-target-comment-missing' :
'discussiontools-target-comments-missing'
).parse(),
{ type: 'warn', autoHide: false }
);
} );
}
}
@ -624,6 +654,13 @@ function highlightNewComments( threadItemSet, noScroll, newCommentIds, newCommen
* @param {ThreadItemSet} threadItemSet
*/
function clearHighlightTargetComment( threadItemSet ) {
if ( missingTargetNotifPromise ) {
missingTargetNotifPromise.then( function ( notif ) {
notif.close();
} );
missingTargetNotifPromise = null;
}
var uri;
try {
uri = new mw.Uri( location.href );