Add some default booleans to Posts and Threads.
Remove timeOfDeath as I won't get to use it anytime soon. Fix #1456.
This commit is contained in:
parent
f8cd67b4ed
commit
b9896b48d2
@ -156,8 +156,8 @@ Index =
|
|||||||
true
|
true
|
||||||
|
|
||||||
threadNode: ->
|
threadNode: ->
|
||||||
return unless data = Index.db.get {boardID: @board.ID, threadID: @ID}
|
return unless Index.db.get {boardID: @board.ID, threadID: @ID}
|
||||||
@pin() if data.isPinned
|
@pin()
|
||||||
catalogNode: ->
|
catalogNode: ->
|
||||||
$.on @nodes.thumb, 'click', Index.onClick
|
$.on @nodes.thumb, 'click', Index.onClick
|
||||||
return if Conf['Image Hover in Catalog']
|
return if Conf['Image Hover in Catalog']
|
||||||
@ -204,17 +204,16 @@ Index =
|
|||||||
ThreadHiding.hide thread
|
ThreadHiding.hide thread
|
||||||
ThreadHiding.saveHiddenState thread
|
ThreadHiding.saveHiddenState thread
|
||||||
togglePin: (thread) ->
|
togglePin: (thread) ->
|
||||||
|
data =
|
||||||
|
boardID: thread.board.ID
|
||||||
|
threadID: thread.ID
|
||||||
if thread.isPinned
|
if thread.isPinned
|
||||||
thread.unpin()
|
thread.unpin()
|
||||||
Index.db.delete
|
Index.db.delete data
|
||||||
boardID: thread.board.ID
|
|
||||||
threadID: thread.ID
|
|
||||||
else
|
else
|
||||||
thread.pin()
|
thread.pin()
|
||||||
Index.db.set
|
data.val = true
|
||||||
boardID: thread.board.ID
|
Index.db.set data
|
||||||
threadID: thread.ID
|
|
||||||
val: isPinned: thread.isPinned
|
|
||||||
Index.sort()
|
Index.sort()
|
||||||
Index.buildIndex()
|
Index.buildIndex()
|
||||||
setIndexMode: (mode) ->
|
setIndexMode: (mode) ->
|
||||||
@ -623,7 +622,7 @@ Index =
|
|||||||
# Sticky threads
|
# Sticky threads
|
||||||
Index.sortOnTop (thread) -> thread.isSticky
|
Index.sortOnTop (thread) -> thread.isSticky
|
||||||
# Highlighted threads
|
# Highlighted threads
|
||||||
Index.sortOnTop (thread) -> thread.isOnTop
|
Index.sortOnTop (thread) -> thread.isOnTop or thread.isPinned
|
||||||
# Non-hidden threads
|
# Non-hidden threads
|
||||||
Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads']
|
Index.sortOnTop((thread) -> !thread.isHidden) if Conf['Anchor Hidden Threads']
|
||||||
sortOnTop: (match) ->
|
sortOnTop: (match) ->
|
||||||
|
|||||||
@ -52,6 +52,9 @@ class Post
|
|||||||
@parseQuotes()
|
@parseQuotes()
|
||||||
@parseFile that
|
@parseFile that
|
||||||
|
|
||||||
|
@isDead = false
|
||||||
|
@isHidden = false
|
||||||
|
|
||||||
@clones = []
|
@clones = []
|
||||||
g.posts[@fullID] = thread.posts[@] = board.posts[@] = @
|
g.posts[@fullID] = thread.posts[@] = board.posts[@] = @
|
||||||
@kill() if that.isArchived
|
@kill() if that.isArchived
|
||||||
@ -62,7 +65,6 @@ class Post
|
|||||||
# Get the comment's text.
|
# Get the comment's text.
|
||||||
# <br> -> \n
|
# <br> -> \n
|
||||||
# Remove:
|
# Remove:
|
||||||
# 'Comment too long'...
|
|
||||||
# EXIF data. (/p/)
|
# EXIF data. (/p/)
|
||||||
# Rolls. (/tg/)
|
# Rolls. (/tg/)
|
||||||
# Preceding and following new lines.
|
# Preceding and following new lines.
|
||||||
@ -149,17 +151,14 @@ class Post
|
|||||||
$.rmClass node, 'desktop'
|
$.rmClass node, 'desktop'
|
||||||
return
|
return
|
||||||
|
|
||||||
kill: (file, now) ->
|
kill: (file) ->
|
||||||
now or= new Date()
|
|
||||||
if file
|
if file
|
||||||
return if @file.isDead
|
return if @file.isDead
|
||||||
@file.isDead = true
|
@file.isDead = true
|
||||||
@file.timeOfDeath = now
|
|
||||||
$.addClass @nodes.root, 'deleted-file'
|
$.addClass @nodes.root, 'deleted-file'
|
||||||
else
|
else
|
||||||
return if @isDead
|
return if @isDead
|
||||||
@isDead = true
|
@isDead = true
|
||||||
@timeOfDeath = now
|
|
||||||
$.addClass @nodes.root, 'deleted-post'
|
$.addClass @nodes.root, 'deleted-post'
|
||||||
|
|
||||||
unless strong = $ 'strong.warning', @nodes.info
|
unless strong = $ 'strong.warning', @nodes.info
|
||||||
@ -171,7 +170,7 @@ class Post
|
|||||||
|
|
||||||
return if @isClone
|
return if @isClone
|
||||||
for clone in @clones
|
for clone in @clones
|
||||||
clone.kill file, now
|
clone.kill file
|
||||||
|
|
||||||
return if file
|
return if file
|
||||||
# Get quotelinks/backlinks to this post
|
# Get quotelinks/backlinks to this post
|
||||||
@ -185,7 +184,6 @@ class Post
|
|||||||
# giving us false-positive dead posts.
|
# giving us false-positive dead posts.
|
||||||
resurrect: ->
|
resurrect: ->
|
||||||
delete @isDead
|
delete @isDead
|
||||||
delete @timeOfDeath
|
|
||||||
$.rmClass @nodes.root, 'deleted-post'
|
$.rmClass @nodes.root, 'deleted-post'
|
||||||
strong = $ 'strong.warning', @nodes.info
|
strong = $ 'strong.warning', @nodes.info
|
||||||
# no false-positive files
|
# no false-positive files
|
||||||
|
|||||||
@ -5,6 +5,10 @@ class Thread
|
|||||||
constructor: (@ID, @board) ->
|
constructor: (@ID, @board) ->
|
||||||
@fullID = "#{@board}.#{@ID}"
|
@fullID = "#{@board}.#{@ID}"
|
||||||
@posts = {}
|
@posts = {}
|
||||||
|
@isDead = false
|
||||||
|
@isHidden = false
|
||||||
|
@isOnTop = false
|
||||||
|
@isPinned = false
|
||||||
@isSticky = false
|
@isSticky = false
|
||||||
@isClosed = false
|
@isClosed = false
|
||||||
@postLimit = false
|
@postLimit = false
|
||||||
@ -52,15 +56,14 @@ class Thread
|
|||||||
(if type is 'Sticky' and @isClosed then $.prepend else $.add) @catalogView.nodes.icons, icon.cloneNode()
|
(if type is 'Sticky' and @isClosed then $.prepend else $.add) @catalogView.nodes.icons, icon.cloneNode()
|
||||||
|
|
||||||
pin: ->
|
pin: ->
|
||||||
@isOnTop = @isPinned = true
|
@isPinned = true
|
||||||
$.addClass @catalogView.nodes.root, 'pinned' if @catalogView
|
$.addClass @catalogView.nodes.root, 'pinned' if @catalogView
|
||||||
unpin: ->
|
unpin: ->
|
||||||
@isOnTop = @isPinned = false
|
@isPinned = false
|
||||||
$.rmClass @catalogView.nodes.root, 'pinned' if @catalogView
|
$.rmClass @catalogView.nodes.root, 'pinned' if @catalogView
|
||||||
|
|
||||||
kill: ->
|
kill: ->
|
||||||
@isDead = true
|
@isDead = true
|
||||||
@timeOfDeath = Date.now()
|
|
||||||
|
|
||||||
collect: ->
|
collect: ->
|
||||||
for postID, post of @posts
|
for postID, post of @posts
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user