Get the cooldown start time at the end of the upload, not when we receive a response from the server:

shorter cooldown period and faster auto-posting.
This commit is contained in:
Nicolas Stepien 2013-02-26 18:49:07 +01:00
parent ee1efc14fb
commit 384a95163d
3 changed files with 16 additions and 8 deletions

View File

@ -5849,7 +5849,7 @@
},
set: function(data) {
var cooldown, hasFile, isReply, isSage, start, type;
start = Date.now();
start = data.req ? data.req.uploadEndTime : Date.now();
if (data.delay) {
cooldown = {
delay: data.delay
@ -5876,15 +5876,14 @@
},
count: function() {
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 {
if (!Object.keys(QR.cooldown.cooldowns).length) {
$["delete"]("" + g.BOARD + ".cooldown");
delete QR.cooldown.isCounting;
delete QR.cooldown.seconds;
QR.status();
return;
}
setTimeout(QR.cooldown.count, 1000);
isReply = g.BOARD.ID === 'f' ? g.VIEW === 'thread' : QR.nodes.thread.value !== 'new';
if (isReply) {
post = QR.replies[0];
@ -6615,6 +6614,7 @@
upCallbacks: {
onload: function() {
QR.req.isUploadFinished = true;
QR.req.uploadEndTime = Date.now();
QR.req.progress = '...';
return QR.status();
},
@ -6686,6 +6686,7 @@
postID: postID
}, QR.nodes.el);
QR.cooldown.set({
req: req,
post: reply,
isReply: !!threadID
});

View File

@ -16,7 +16,9 @@ beta
Delete links in the post menu will only appear for your posts.
QR changes:
Cooldown start time is now more accurate, which means shorter cooldown period and faster auto-posting.
Clicking the submit button while uploading will abort the upload and won't start re-uploading automatically anymore.
Closing the QR while uploading will abort the upload and won't close the QR anymore.
Creating threads outside of the index is now possible.
Selection-to-quote also applies to selected text inside the post, not just inside the comment.
Quoting the OP will not insert the >>opnumber anymore unless the QR was already opened.

View File

@ -159,7 +159,10 @@ QR =
QR.cooldown.cooldowns[id] = cooldowns[id]
QR.cooldown.start()
set: (data) ->
start = Date.now()
start = if data.req
data.req.uploadEndTime
else
Date.now()
if data.delay
cooldown = delay: data.delay
else
@ -186,15 +189,15 @@ QR =
delete QR.cooldown.cooldowns[id]
$.set "cooldown.#{g.BOARD}", QR.cooldown.cooldowns
count: ->
if Object.keys(QR.cooldown.cooldowns).length
setTimeout QR.cooldown.count, 1000
else
unless Object.keys(QR.cooldown.cooldowns).length
$.delete "#{g.BOARD}.cooldown"
delete QR.cooldown.isCounting
delete QR.cooldown.seconds
QR.status()
return
setTimeout QR.cooldown.count, 1000
isReply = if g.BOARD.ID is 'f'
g.VIEW is 'thread'
else
@ -826,6 +829,7 @@ QR =
onload: ->
# Upload done, waiting for server response.
QR.req.isUploadFinished = true
QR.req.uploadEndTime = Date.now()
QR.req.progress = '...'
QR.status()
onprogress: (e) ->
@ -912,6 +916,7 @@ QR =
}, QR.nodes.el
QR.cooldown.set
req: req
post: reply
isReply: !!threadID