From 3e211c8ba7980e68b86a8ca2e3dd0ce775683aca Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 2 Apr 2013 23:28:22 +0200 Subject: [PATCH] Prevent file upload in threads that reached the file limit. Fix QR preventing from posting in sticky thread instead of locked thread. --- src/features.coffee | 21 +++++++++++---------- src/qr.coffee | 4 +++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/features.coffee b/src/features.coffee index 206eb461e..0aac59152 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -3794,19 +3794,20 @@ ThreadStats = for ID, post of @posts postCount++ fileCount++ if post.file - ThreadStats.update postCount, fileCount ThreadStats.thread = @ + ThreadStats.update postCount, fileCount $.on d, 'ThreadUpdate', ThreadStats.onUpdate $.add d.body, ThreadStats.dialog onUpdate: (e) -> return if e.detail[404] - {postCount, fileCount, postLimit, fileLimit} = e.detail - ThreadStats.update postCount, fileCount, postLimit, fileLimit - update: (postCount, fileCount, postLimit, fileLimit) -> - ThreadStats.postCountEl.textContent = postCount - ThreadStats.fileCountEl.textContent = fileCount - (if postLimit and !ThreadStats.thread.isSticky then $.addClass else $.rmClass) ThreadStats.postCountEl, 'warning' - (if fileLimit and !ThreadStats.thread.isSticky then $.addClass else $.rmClass) ThreadStats.fileCountEl, 'warning' + {postCount, fileCount} = e.detail + ThreadStats.update postCount, fileCount + update: (postCount, fileCount) -> + {thread, postCountEl, fileCountEl} = ThreadStats + postCountEl.textContent = postCount + fileCountEl.textContent = fileCount + (if thread.postLimit and !thread.isSticky then $.addClass else $.rmClass) postCountEl, 'warning' + (if thread.fileLimit and !thread.isSticky then $.addClass else $.rmClass) fileCountEl, 'warning' ThreadUpdater = init: -> @@ -4010,6 +4011,8 @@ ThreadUpdater = ThreadUpdater.updateThreadStatus 'Sticky', OP ThreadUpdater.updateThreadStatus 'Closed', OP + ThreadUpdater.thread.postLimit = !!OP.bumplimit + ThreadUpdater.thread.fileLimit = !!OP.imagelimit nodes = [] # post container elements posts = [] # post objects @@ -4085,8 +4088,6 @@ ThreadUpdater = deletedFiles: deletedFiles postCount: OP.replies + 1 fileCount: OP.images + (!!ThreadUpdater.thread.OP.file and !ThreadUpdater.thread.OP.file.isDead) - postLimit: !!OP.bumplimit - fileLimit: !!OP.imagelimit ThreadWatcher = init: -> diff --git a/src/qr.coffee b/src/qr.coffee index e077266f8..c25304397 100644 --- a/src/qr.coffee +++ b/src/qr.coffee @@ -836,10 +836,12 @@ QR = err = 'New threads require a subject.' else unless post.file or textOnly = !!$ 'input[name=textonly]', $.id 'postForm' err = 'No file selected.' - else if g.BOARD.threads[threadID].isSticky + else if g.BOARD.threads[threadID].isClosed err = 'You can\'t reply to this thread anymore.' else unless post.com or post.file err = 'No file selected.' + else if post.file and g.BOARD.threads[threadID].fileLimit + err = 'Max limit of image replies has been reached.' if QR.captcha.isEnabled and !err {challenge, response} = QR.captcha.getOne()