Dereference dead threads.

I wonder if this will be enough...
This commit is contained in:
Mayhem 2013-10-31 03:13:44 +01:00
parent c2984275e5
commit 21e6902762
4 changed files with 25 additions and 4 deletions

View File

@ -1,5 +1,5 @@
Index navigation improvements:
- You can now refresh the index page you are on with the same keybind for refreshing threads.
- You can now refresh the index page you are on with the icon in the header bar or the same keybind for refreshing threads.
- You can now switch between single-page and all-pages navigation via the "Index Navigation" header sub-menu.
Added a keybind to open the catalog search field on index pages.

View File

@ -193,6 +193,13 @@ class Post
quotelink.textContent = quotelink.textContent.replace '\u00A0(Dead)', ''
$.rmClass quotelink, 'deadlink'
return
collect: ->
@kill()
delete g.posts[@fullID]
delete @thread.posts[@]
delete @board.posts[@]
addClone: (context) ->
new Clone @, context
rmClone: (index) ->

View File

@ -11,3 +11,9 @@ class Thread
kill: ->
@isDead = true
@timeOfDeath = Date.now()
collect: ->
for postID, post in @posts
post.collect()
delete g.threads[@fullID]
delete @board.threads[@]

View File

@ -84,15 +84,17 @@ Index =
for page in pages
dataThr.push page.threads...
nodes = []
threads = []
posts = []
nodes = []
threads = []
liveThreads = []
posts = []
for data in dataThr
threadRoot = Build.thread g.BOARD, data
nodes.push threadRoot, $.el 'hr'
unless thread = g.threads["#{g.BOARD}.#{data.no}"]
thread = new Thread data.no, g.BOARD
threads.push thread
liveThreads.push thread
for postRoot in $$ '.thread > .postContainer', threadRoot
continue if thread.posts[postRoot.id.match /\d+/]
try
@ -106,6 +108,7 @@ Index =
error: err
Main.handleErrors errors if errors
Index.collectDeadThreads liveThreads
# Add the threads and <hr>s in a container to make sure all features work.
$.nodes nodes
Main.callbackNodes Thread, threads
@ -128,3 +131,8 @@ Index =
arr = nodes.splice nodes.indexOf(top), 2
nodes.splice i * 2, 0, arr...
nodes
collectDeadThreads: (liveThreads) ->
for threadID, thread of g.threads when thread not in liveThreads
thread.collect()
return