X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fajax%2FGetTimesAjaxPage.java;h=7aa6779f6f0b5d36c27b6bd7709762e5657ada65;hp=13cf424ba7bfcc802b6e663fa3aa7de8d1d09bbc;hb=93fdf9e218d808f65f618abbddce183191d8c15b;hpb=3b751d0c053450961bb66d2507d6187ce56f8785 diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java index 13cf424..7aa6779 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetTimesAjaxPage.java @@ -28,6 +28,8 @@ import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; +import com.google.common.base.Optional; + /** * Ajax page that returns a formatted, relative timestamp for replies or posts. * @@ -77,16 +79,16 @@ public class GetTimesAjaxPage extends JsonPage { if (allIds.length() > 0) { String[] ids = allIds.split(","); for (String id : ids) { - PostReply reply = webInterface.getCore().getPostReply(id); - if (reply == null) { + Optional reply = webInterface.getCore().getPostReply(id); + if (!reply.isPresent()) { continue; } JsonObject replyTime = new JsonObject(); - Time time = getTime(reply.getTime()); + Time time = getTime(reply.get().getTime()); replyTime.put("timeText", time.getText()); replyTime.put("refreshTime", TimeUnit.MILLISECONDS.toSeconds(time.getRefresh())); synchronized (dateFormat) { - replyTime.put("tooltip", dateFormat.format(new Date(reply.getTime()))); + replyTime.put("tooltip", dateFormat.format(new Date(reply.get().getTime()))); } replyTimes.put(id, replyTime); }