Tiny refactor.

This commit is contained in:
Nicolas Stepien 2012-10-05 16:20:37 +02:00
parent 3c67717471
commit 4b1391a81b
2 changed files with 14 additions and 18 deletions

View File

@ -1934,13 +1934,12 @@
} }
continue; continue;
} }
type = isReply && cooldown.isReply ? isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post' : !(isReply || cooldown.isReply) ? 'thread' : void 0; if (isReply === cooldown.isReply) {
if (type) { type = !isReply ? 'thread' : isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post';
elapsed = Math.floor((now - start) / 1000); elapsed = Math.floor((now - start) / 1000);
if (elapsed >= 0) { if (elapsed >= 0) {
seconds = Math.max(seconds, types[type] - elapsed); seconds = Math.max(seconds, types[type] - elapsed);
} }
type = '';
} }
if (!((start <= now && now <= cooldown.timeout))) { if (!((start <= now && now <= cooldown.timeout))) {
QR.cooldown.unset(start); QR.cooldown.unset(start);

View File

@ -1451,13 +1451,12 @@ QR =
type = type =
unless isReply unless isReply
'thread' 'thread'
else if isSage
'sage'
else if hasFile
'file'
else else
if isSage 'post'
'sage'
else if hasFile
'file'
else
'post'
cooldown = cooldown =
isReply: isReply isReply: isReply
isSage: isSage isSage: isSage
@ -1496,23 +1495,21 @@ QR =
QR.cooldown.unset start QR.cooldown.unset start
continue continue
# Only cooldowns relevant to this post can set the seconds value. if isReply is cooldown.isReply
# Unset outdated cooldowns that can no longer impact us. # Only cooldowns relevant to this post can set the seconds value.
type = # Unset outdated cooldowns that can no longer impact us.
if isReply and cooldown.isReply type =
if isSage and cooldown.isSage unless isReply
'thread'
else if isSage and cooldown.isSage
'sage' 'sage'
else if hasFile and cooldown.hasFile else if hasFile and cooldown.hasFile
'file' 'file'
else else
'post' 'post'
else unless isReply or cooldown.isReply
'thread'
if type
elapsed = Math.floor (now - start) / 1000 elapsed = Math.floor (now - start) / 1000
if elapsed >= 0 # clock changed since then? if elapsed >= 0 # clock changed since then?
seconds = Math.max seconds, types[type] - elapsed seconds = Math.max seconds, types[type] - elapsed
type = ''
unless start <= now <= cooldown.timeout unless start <= now <= cooldown.timeout
QR.cooldown.unset start QR.cooldown.unset start