From: David ‘Bombe’ Roden Date: Wed, 26 Mar 2014 18:45:28 +0000 (+0100) Subject: Move parsing of boolean options into its own method. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=53118f28d539f78373a4e0724162cd3ef3fb2353;p=Sone.git Move parsing of boolean options into its own method. --- diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java index 53c5977..008a1ce 100644 --- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java +++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java @@ -61,16 +61,11 @@ public class OptionsPage extends SoneTemplatePage { if (request.getMethod() == Method.POST) { List fieldErrors = new ArrayList(); if (currentSone != null) { - boolean autoFollow = request.getHttpRequest().isPartSet("auto-follow"); - currentSone.getOptions().getBooleanOption("AutoFollow").set(autoFollow); - boolean enableSoneInsertNotifications = request.getHttpRequest().isPartSet("enable-sone-insert-notifications"); - currentSone.getOptions().getBooleanOption("EnableSoneInsertNotifications").set(enableSoneInsertNotifications); - boolean showNotificationNewSones = request.getHttpRequest().isPartSet("show-notification-new-sones"); - currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").set(showNotificationNewSones); - boolean showNotificationNewPosts = request.getHttpRequest().isPartSet("show-notification-new-posts"); - currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").set(showNotificationNewPosts); - boolean showNotificationNewReplies = request.getHttpRequest().isPartSet("show-notification-new-replies"); - currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").set(showNotificationNewReplies); + setBooleanOption(request, currentSone, "auto-follow", "AutoFollow"); + setBooleanOption(request, currentSone, "enable-sone-insert-notifications", "EnableSoneInsertNotifications"); + setBooleanOption(request, currentSone, "show-notification-new-sones", "ShowNotification/NewSones"); + setBooleanOption(request, currentSone, "show-notification-new-posts", "ShowNotification/NewPosts"); + setBooleanOption(request, currentSone, "show-notification-new-replies", "ShowNotification/NewReplies"); String showCustomAvatars = request.getHttpRequest().getPartAsStringFailsafe("show-custom-avatars", 32); currentSone.getOptions(). getEnumOption("ShowCustomAvatars").set(ShowCustomAvatars.valueOf(showCustomAvatars)); webInterface.getCore().touchConfiguration(); @@ -156,4 +151,9 @@ public class OptionsPage extends SoneTemplatePage { templateContext.set("fcp-full-access-required", preferences.getFcpFullAccessRequired().ordinal()); } + private void setBooleanOption(FreenetRequest request, Sone currentSone, String requestPartName, String optionName) { + boolean autoFollow = request.getHttpRequest().isPartSet(requestPartName); + currentSone.getOptions().getBooleanOption(optionName).set(autoFollow); + } + }