diff --git a/CHANGELOG.md b/CHANGELOG.md index 69308c0cb..352ef32a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/General/Post.coffee b/src/General/Post.coffee index 27811afa5..901405495 100644 --- a/src/General/Post.coffee +++ b/src/General/Post.coffee @@ -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) -> diff --git a/src/General/Thread.coffee b/src/General/Thread.coffee index 1f15bf714..97502ecd2 100644 --- a/src/General/Thread.coffee +++ b/src/General/Thread.coffee @@ -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[@] diff --git a/src/Miscellaneous/Index.coffee b/src/Miscellaneous/Index.coffee index ea978a3fc..e06236f2c 100644 --- a/src/Miscellaneous/Index.coffee +++ b/src/Miscellaneous/Index.coffee @@ -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
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