-
Notifications
You must be signed in to change notification settings - Fork 7
Check block status change when issuing warning, and vice versa #319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,7 +13,7 @@ | |||||
* etc.), as well as the rollback success page | ||||||
*/ | ||||||
|
||||||
var conv = require('ext.gadget.HanAssist').conv; | ||||||
var conv = require('ext.gadget.HanAssist').conv, initialBlockId, initialBlockInfo; | ||||||
|
||||||
Twinkle.warn = function twinklewarn() { | ||||||
|
||||||
|
@@ -117,7 +117,6 @@ Twinkle.warn.callback = function twinklewarnCallback() { | |||||
!confirm(conv({ hans: '您将要警告自己!您确定要继续吗?', hant: '您將要警告自己!您確定要繼續嗎?' }))) { | ||||||
return; | ||||||
} | ||||||
|
||||||
var dialog; | ||||||
Twinkle.warn.dialog = new Morebits.simpleWindow(600, 440); | ||||||
dialog = Twinkle.warn.dialog; | ||||||
|
@@ -285,6 +284,10 @@ Twinkle.warn.callback = function twinklewarnCallback() { | |||||
Twinkle.warn.isFlow = false; | ||||||
init(); | ||||||
}); | ||||||
Twinkle.block.fetchUserInfo(function () { | ||||||
initialBlockId = Twinkle.block.blockLogId; | ||||||
initialBlockInfo = Twinkle.block.currentBlockInfo; | ||||||
}); | ||||||
}; | ||||||
|
||||||
// This is all the messages that might be dispatched by the code | ||||||
|
@@ -1911,20 +1914,28 @@ Twinkle.warn.callback.evaluate = function twinklewarnCallbackEvaluate(e) { | |||||
|
||||||
Morebits.simpleWindow.setButtonsEnabled(false); | ||||||
Morebits.status.init(e.target); | ||||||
Twinkle.block.fetchUserInfo(function () { | ||||||
if (initialBlockId !== Twinkle.block.blockLogId || !!initialBlockInfo !== !!Twinkle.block.currentBlockInfo) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The asynchronous fetching of block info followed by a check using '!!initialBlockInfo' may be unclear. Consider adding a comment or refactoring the boolean check to explicitly compare for null/undefined to improve readability and maintainability.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||
var newBlockMessage = conv({ hans: '此用户的封禁状态发生变化,确定继续发出警告?', hant: '此使用者的封鎖狀態發生變化,確定繼續發出警告?' }); | ||||||
if (!confirm(newBlockMessage)) { | ||||||
Morebits.status.error(conv({ hans: '警告、提醒用户', hant: '警告、提醒使用者' }), conv({ hans: '用户取消操作', hant: '使用者取消操作' })); | ||||||
return; | ||||||
} | ||||||
} | ||||||
Morebits.wiki.actionCompleted.redirect = userTalkPage; | ||||||
Morebits.wiki.actionCompleted.notice = conv({ hans: '警告完成,将在几秒后刷新', hant: '警告完成,將在幾秒後重新整理' }); | ||||||
|
||||||
Morebits.wiki.actionCompleted.redirect = userTalkPage; | ||||||
Morebits.wiki.actionCompleted.notice = conv({ hans: '警告完成,将在几秒后刷新', hant: '警告完成,將在幾秒後重新整理' }); | ||||||
|
||||||
if (Twinkle.warn.isFlow) { | ||||||
var flow_page = new Morebits.wiki.flow(userTalkPage, conv({ hans: '用户Flow讨论页留言', hant: '使用者Flow討論頁留言' })); | ||||||
flow_page.setCallbackParameters(params); | ||||||
Twinkle.warn.callbacks.main_flow(flow_page); | ||||||
} else { | ||||||
var wikipedia_page = new Morebits.wiki.page(userTalkPage, conv({ hans: '用户讨论页修改', hant: '使用者討論頁修改' })); | ||||||
wikipedia_page.setCallbackParameters(params); | ||||||
wikipedia_page.setFollowRedirect(true, false); | ||||||
wikipedia_page.load(Twinkle.warn.callbacks.main); | ||||||
} | ||||||
if (Twinkle.warn.isFlow) { | ||||||
var flow_page = new Morebits.wiki.flow(userTalkPage, conv({ hans: '用户Flow讨论页留言', hant: '使用者Flow討論頁留言' })); | ||||||
flow_page.setCallbackParameters(params); | ||||||
Twinkle.warn.callbacks.main_flow(flow_page); | ||||||
} else { | ||||||
var wikipedia_page = new Morebits.wiki.page(userTalkPage, conv({ hans: '用户讨论页修改', hant: '使用者討論頁修改' })); | ||||||
wikipedia_page.setCallbackParameters(params); | ||||||
wikipedia_page.setFollowRedirect(true, false); | ||||||
wikipedia_page.load(Twinkle.warn.callbacks.main); | ||||||
} | ||||||
}); | ||||||
}; | ||||||
|
||||||
Twinkle.addInitCallback(Twinkle.warn, 'warn'); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code assumes that the revisions property exists when the page key is not '-1'. Consider adding a safeguard to verify that the revisions array exists and is non-empty before accessing its first element to avoid potential runtime errors.
Copilot uses AI. Check for mistakes.