From b9896b48d2b44d13a9ce7df64bb47e53d30716dd Mon Sep 17 00:00:00 2001 From: Mayhem Date: Mon, 17 Feb 2014 18:02:32 +0100 Subject: [PATCH] Add some default booleans to Posts and Threads. Remove timeOfDeath as I won't get to use it anytime soon. Fix #1456. --- src/General/Index.coffee | 19 +++++++++---------- src/General/Post.coffee | 12 +++++------- src/General/Thread.coffee | 9 ++++++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/General/Index.coffee b/src/General/Index.coffee index bc484e48e..2e794b116 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -156,8 +156,8 @@ Index = true threadNode: -> - return unless data = Index.db.get {boardID: @board.ID, threadID: @ID} - @pin() if data.isPinned + return unless Index.db.get {boardID: @board.ID, threadID: @ID} + @pin() catalogNode: -> $.on @nodes.thumb, 'click', Index.onClick return if Conf['Image Hover in Catalog'] @@ -204,17 +204,16 @@ Index = ThreadHiding.hide thread ThreadHiding.saveHiddenState thread togglePin: (thread) -> + data = + boardID: thread.board.ID + threadID: thread.ID if thread.isPinned thread.unpin() - Index.db.delete - boardID: thread.board.ID - threadID: thread.ID + Index.db.delete data else thread.pin() - Index.db.set - boardID: thread.board.ID - threadID: thread.ID - val: isPinned: thread.isPinned + data.val = true + Index.db.set data Index.sort() Index.buildIndex() setIndexMode: (mode) -> @@ -623,7 +622,7 @@ Index = # Sticky threads Index.sortOnTop (thread) -> thread.isSticky # Highlighted threads - Index.sortOnTop (thread) -> thread.isOnTop + Index.sortOnTop (thread) -> thread.isOnTop or thread.isPinned # Non-hidden threads Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads'] sortOnTop: (match) -> diff --git a/src/General/Post.coffee b/src/General/Post.coffee index b88c12cd6..5d5b63ed1 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -52,6 +52,9 @@ class Post @parseQuotes() @parseFile that + @isDead = false + @isHidden = false + @clones = [] g.posts[@fullID] = thread.posts[@] = board.posts[@] = @ @kill() if that.isArchived @@ -62,7 +65,6 @@ class Post # Get the comment's text. #
-> \n # Remove: - # 'Comment too long'... # EXIF data. (/p/) # Rolls. (/tg/) # Preceding and following new lines. @@ -149,17 +151,14 @@ class Post $.rmClass node, 'desktop' return - kill: (file, now) -> - now or= new Date() + kill: (file) -> if file return if @file.isDead @file.isDead = true - @file.timeOfDeath = now $.addClass @nodes.root, 'deleted-file' else return if @isDead @isDead = true - @timeOfDeath = now $.addClass @nodes.root, 'deleted-post' unless strong = $ 'strong.warning', @nodes.info @@ -171,7 +170,7 @@ class Post return if @isClone for clone in @clones - clone.kill file, now + clone.kill file return if file # Get quotelinks/backlinks to this post @@ -185,7 +184,6 @@ class Post # giving us false-positive dead posts. resurrect: -> delete @isDead - delete @timeOfDeath $.rmClass @nodes.root, 'deleted-post' strong = $ 'strong.warning', @nodes.info # no false-positive files diff --git a/src/General/Thread.coffee b/src/General/Thread.coffee index 1cdd9a957..b930661c8 100644 --- a/src/General/Thread.coffee +++ b/src/General/Thread.coffee @@ -5,6 +5,10 @@ class Thread constructor: (@ID, @board) -> @fullID = "#{@board}.#{@ID}" @posts = {} + @isDead = false + @isHidden = false + @isOnTop = false + @isPinned = false @isSticky = false @isClosed = false @postLimit = false @@ -52,15 +56,14 @@ class Thread (if type is 'Sticky' and @isClosed then $.prepend else $.add) @catalogView.nodes.icons, icon.cloneNode() pin: -> - @isOnTop = @isPinned = true + @isPinned = true $.addClass @catalogView.nodes.root, 'pinned' if @catalogView unpin: -> - @isOnTop = @isPinned = false + @isPinned = false $.rmClass @catalogView.nodes.root, 'pinned' if @catalogView kill: -> @isDead = true - @timeOfDeath = Date.now() collect: -> for postID, post of @posts