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: 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. - 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. 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)', '' quotelink.textContent = quotelink.textContent.replace '\u00A0(Dead)', ''
$.rmClass quotelink, 'deadlink' $.rmClass quotelink, 'deadlink'
return return
collect: ->
@kill()
delete g.posts[@fullID]
delete @thread.posts[@]
delete @board.posts[@]
addClone: (context) -> addClone: (context) ->
new Clone @, context new Clone @, context
rmClone: (index) -> rmClone: (index) ->

View File

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