Add some default booleans to Posts and Threads.
Remove timeOfDeath as I won't get to use it anytime soon. Fix #1456. Conflicts: src/General/lib/thread.class
This commit is contained in:
parent
5df20a84dc
commit
12c319dd23
@ -179,8 +179,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
|
||||
onClick: (e) ->
|
||||
@ -203,17 +203,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()
|
||||
|
||||
@ -516,7 +515,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']
|
||||
|
||||
|
||||
@ -76,6 +76,9 @@ class Post
|
||||
@parseQuotes()
|
||||
@parseFile that
|
||||
|
||||
@isDead = false
|
||||
@isHidden = false
|
||||
|
||||
@clones = []
|
||||
g.posts.push @fullID, thread.posts.push @, board.posts.push @, @
|
||||
@kill() if that.isArchived
|
||||
@ -175,17 +178,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
|
||||
@ -197,7 +197,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
|
||||
@ -210,7 +210,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
|
||||
|
||||
@ -5,6 +5,10 @@ class Thread
|
||||
constructor: (@ID, @board) ->
|
||||
@fullID = "#{@board}.#{@ID}"
|
||||
@posts = new SimpleDict
|
||||
@isDead = false
|
||||
@isHidden = false
|
||||
@isOnTop = false
|
||||
@isPinned = false
|
||||
@isSticky = false
|
||||
@isClosed = false
|
||||
@postLimit = false
|
||||
@ -55,15 +59,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: ->
|
||||
@posts.forEach (post) -> post.collect()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user