Add possibility to unbookmark all not loaded posts at once.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Mar 2011 07:43:45 +0000 (08:43 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Sat, 12 Mar 2011 07:43:45 +0000 (08:43 +0100)
src/main/java/net/pterodactylus/sone/web/UnbookmarkPage.java

index 85a0359..85f46f0 100644 (file)
@@ -17,6 +17,9 @@
 
 package net.pterodactylus.sone.web;
 
+import java.util.Set;
+
+import net.pterodactylus.sone.data.Post;
 import net.pterodactylus.sone.web.page.Page.Request.Method;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
@@ -54,6 +57,16 @@ public class UnbookmarkPage extends SoneTemplatePage {
                        webInterface.getCore().unbookmarkPost(id);
                        throw new RedirectException(returnPage);
                }
+               String id = request.getHttpRequest().getParam("post");
+               if (id.equals("allNotLoaded")) {
+                       Set<Post> posts = webInterface.getCore().getBookmarkedPosts();
+                       for (Post post : posts) {
+                               if (post.getSone() == null) {
+                                       webInterface.getCore().unbookmark(post);
+                               }
+                       }
+                       throw new RedirectException("bookmarks.html");
+               }
        }
 
 }