mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-04-05 03:00:15 -04:00
Display message when a form is ratelimited.
This commit is contained in:
@@ -178,6 +178,7 @@ Note: there are a couple of places outside of your subreddit where someone can c
|
||||
|
||||
an_error_occurred = _("an error occurred"),
|
||||
an_error_occurred_friendly = _("an error occurred. please try again later!"),
|
||||
rate_limit = _("please wait a few seconds and try again."),
|
||||
)
|
||||
|
||||
class StringHandler(object):
|
||||
|
||||
@@ -169,8 +169,16 @@ $.request = function(op, parameters, worker_in, block, type,
|
||||
var action = op;
|
||||
var worker = worker_in;
|
||||
|
||||
if (rate_limit(op) || (window != window.top && !reddit.cnameframe && !reddit.external_frame))
|
||||
return;
|
||||
if (rate_limit(op)) {
|
||||
if (errorhandler) {
|
||||
errorhandler('ratelimit')
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (window != window.top && !reddit.cnameframe && !reddit.external_frame) {
|
||||
return
|
||||
}
|
||||
|
||||
/* we have a lock if we are not blocking or if we have gotten a lock */
|
||||
var have_lock = !$.with_default(block, false) || acquire_ajax_lock(action);
|
||||
|
||||
@@ -98,10 +98,14 @@ function get_form_fields(form, fields, filter_func) {
|
||||
};
|
||||
|
||||
function form_error(form) {
|
||||
return function(r) {
|
||||
$(form).find(".status")
|
||||
.html("an error occurred while posting " +
|
||||
"(status: " + r.status + ")").end();
|
||||
return function(req) {
|
||||
var msg
|
||||
if (req == 'ratelimit') {
|
||||
msg = r.strings.rate_limit
|
||||
} else {
|
||||
msg = 'an error occurred while posting (status: ' + req.status + ')'
|
||||
}
|
||||
$(form).find('.status').text(msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user