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

View File

@ -16,7 +16,9 @@ beta
Delete links in the post menu will only appear for your posts. Delete links in the post menu will only appear for your posts.
QR changes: 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. 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. 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. 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. 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.cooldowns[id] = cooldowns[id]
QR.cooldown.start() QR.cooldown.start()
set: (data) -> set: (data) ->
start = Date.now() start = if data.req
data.req.uploadEndTime
else
Date.now()
if data.delay if data.delay
cooldown = delay: data.delay cooldown = delay: data.delay
else else
@ -186,15 +189,15 @@ QR =
delete QR.cooldown.cooldowns[id] delete QR.cooldown.cooldowns[id]
$.set "cooldown.#{g.BOARD}", QR.cooldown.cooldowns $.set "cooldown.#{g.BOARD}", QR.cooldown.cooldowns
count: -> count: ->
if Object.keys(QR.cooldown.cooldowns).length unless Object.keys(QR.cooldown.cooldowns).length
setTimeout QR.cooldown.count, 1000
else
$.delete "#{g.BOARD}.cooldown" $.delete "#{g.BOARD}.cooldown"
delete QR.cooldown.isCounting delete QR.cooldown.isCounting
delete QR.cooldown.seconds delete QR.cooldown.seconds
QR.status() QR.status()
return return
setTimeout QR.cooldown.count, 1000
isReply = if g.BOARD.ID is 'f' isReply = if g.BOARD.ID is 'f'
g.VIEW is 'thread' g.VIEW is 'thread'
else else
@ -826,6 +829,7 @@ QR =
onload: -> onload: ->
# Upload done, waiting for server response. # Upload done, waiting for server response.
QR.req.isUploadFinished = true QR.req.isUploadFinished = true
QR.req.uploadEndTime = Date.now()
QR.req.progress = '...' QR.req.progress = '...'
QR.status() QR.status()
onprogress: (e) -> onprogress: (e) ->
@ -912,6 +916,7 @@ QR =
}, QR.nodes.el }, QR.nodes.el
QR.cooldown.set QR.cooldown.set
req: req
post: reply post: reply
isReply: !!threadID isReply: !!threadID