Some cooldown concurrency fixes. It still needs some more testing.
This commit is contained in:
parent
c2491a7f66
commit
6bafe5189c
@ -1829,7 +1829,7 @@
|
||||
disabled = true;
|
||||
QR.cooldown.auto = false;
|
||||
}
|
||||
value = QR.cooldown.seconds || data.progress || value;
|
||||
value = data.progress || QR.cooldown.seconds || value;
|
||||
input = QR.status.input;
|
||||
input.value = QR.cooldown.auto && Conf['Cooldown'] ? value ? "Auto " + value : 'Auto' : value || 'Submit';
|
||||
return input.disabled = disabled || false;
|
||||
@ -1868,7 +1868,10 @@
|
||||
return QR.cooldown.count();
|
||||
},
|
||||
sync: function(cooldowns) {
|
||||
QR.cooldown.cooldowns = cooldowns;
|
||||
var id;
|
||||
for (id in cooldowns) {
|
||||
QR.cooldown.cooldowns[id] = cooldowns[id];
|
||||
}
|
||||
return QR.cooldown.start();
|
||||
},
|
||||
set: function(data) {
|
||||
@ -1902,12 +1905,14 @@
|
||||
return $.set("" + g.BOARD + ".cooldown", QR.cooldown.cooldowns);
|
||||
},
|
||||
count: function() {
|
||||
var cooldown, cooldowns, elapsed, hasFile, isReply, isSage, now, post, seconds, start, type, types, _ref;
|
||||
var cooldown, cooldowns, elapsed, hasFile, isReply, isSage, now, post, seconds, start, type, types, update, _ref;
|
||||
if (Object.keys(QR.cooldown.cooldowns).length) {
|
||||
setTimeout(QR.cooldown.count, 1000);
|
||||
} else {
|
||||
$["delete"]("" + g.BOARD + ".cooldown");
|
||||
QR.cooldown.isCounting = false;
|
||||
delete QR.cooldown.isCounting;
|
||||
delete QR.cooldown.seconds;
|
||||
QR.status();
|
||||
return;
|
||||
}
|
||||
if ((isReply = g.REPLY ? true : QR.threadSelector.value !== 'new')) {
|
||||
@ -1929,7 +1934,7 @@
|
||||
}
|
||||
continue;
|
||||
}
|
||||
type = isReply && cooldown.isReply ? isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post' : !(isReply || cooldown.isReply) ? type = 'thread' : void 0;
|
||||
type = isReply && cooldown.isReply ? isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post' : !(isReply || cooldown.isReply) ? 'thread' : void 0;
|
||||
if (type) {
|
||||
elapsed = Math.floor((now - start) / 1000);
|
||||
if (elapsed >= 0) {
|
||||
@ -1941,8 +1946,9 @@
|
||||
QR.cooldown.unset(start);
|
||||
}
|
||||
}
|
||||
update = seconds !== null || !!QR.cooldown.seconds;
|
||||
QR.cooldown.seconds = seconds;
|
||||
if (seconds !== null) {
|
||||
if (update) {
|
||||
QR.status();
|
||||
}
|
||||
if (seconds === 0 && QR.cooldown.auto) {
|
||||
|
||||
@ -1406,7 +1406,7 @@ QR =
|
||||
value = 404
|
||||
disabled = true
|
||||
QR.cooldown.auto = false
|
||||
value = QR.cooldown.seconds or data.progress or value
|
||||
value = data.progress or QR.cooldown.seconds or value
|
||||
{input} = QR.status
|
||||
input.value =
|
||||
if QR.cooldown.auto and Conf['Cooldown']
|
||||
@ -1434,7 +1434,10 @@ QR =
|
||||
QR.cooldown.isCounting = true
|
||||
QR.cooldown.count()
|
||||
sync: (cooldowns) ->
|
||||
QR.cooldown.cooldowns = cooldowns
|
||||
# Add each cooldowns, don't overwrite everything in case we
|
||||
# still need to purge one in the current tab to auto-post.
|
||||
for id of cooldowns
|
||||
QR.cooldown.cooldowns[id] = cooldowns[id]
|
||||
QR.cooldown.start()
|
||||
set: (data) ->
|
||||
return unless Conf['Cooldown']
|
||||
@ -1471,7 +1474,9 @@ QR =
|
||||
setTimeout QR.cooldown.count, 1000
|
||||
else
|
||||
$.delete "#{g.BOARD}.cooldown"
|
||||
QR.cooldown.isCounting = false
|
||||
delete QR.cooldown.isCounting
|
||||
delete QR.cooldown.seconds
|
||||
QR.status()
|
||||
return
|
||||
|
||||
if (isReply = if g.REPLY then true else QR.threadSelector.value isnt 'new')
|
||||
@ -1502,7 +1507,7 @@ QR =
|
||||
else
|
||||
'post'
|
||||
else unless isReply or cooldown.isReply
|
||||
type = 'thread'
|
||||
'thread'
|
||||
if type
|
||||
elapsed = Math.floor (now - start) / 1000
|
||||
if elapsed >= 0 # clock changed since then?
|
||||
@ -1511,8 +1516,12 @@ QR =
|
||||
unless start <= now <= cooldown.timeout
|
||||
QR.cooldown.unset start
|
||||
|
||||
# Update the status when we change posting type.
|
||||
# Don't get stuck at some random number.
|
||||
# Don't interfere with progress status updates.
|
||||
update = seconds isnt null or !!QR.cooldown.seconds
|
||||
QR.cooldown.seconds = seconds
|
||||
QR.status() if seconds isnt null
|
||||
QR.status() if update
|
||||
QR.submit() if seconds is 0 and QR.cooldown.auto
|
||||
|
||||
quote: (e) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user