X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2FWebInterface.java;h=c1c0653673cdd00b47fdd9152f3ca63222268ba1;hp=2ea755b6d288958f7c8939bdbaea0aca2c0a2a65;hb=316b9c2b3d16792975434644ae39a9b1814f32c4;hpb=0da3fe68ecd25fdfc5eca94f939288c9f6273940 diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 2ea755b..c1c0653 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -249,7 +249,22 @@ public class WebInterface implements CoreListener { * currently logged in */ public Sone getCurrentSone(ToadletContext toadletContext) { - return getCurrentSone(getCurrentSession(toadletContext)); + return getCurrentSone(toadletContext, true); + } + + /** + * Returns the currently logged in Sone. + * + * @param toadletContext + * The toadlet context + * @param create + * {@code true} to create a new session if no session exists, + * {@code false} to not create a new session + * @return The currently logged in Sone, or {@code null} if no Sone is + * currently logged in + */ + public Sone getCurrentSone(ToadletContext toadletContext, boolean create) { + return getCurrentSone(getCurrentSession(toadletContext, create)); } /** @@ -672,6 +687,7 @@ public class WebInterface implements CoreListener { @SuppressWarnings("synthetic-access") public void run() { lockedSonesNotification.add(sone); + lockedSonesTickerObjects.remove(sone); notificationManager.addNotification(lockedSonesNotification); } }, "Sone Locked Notification"); @@ -683,12 +699,8 @@ public class WebInterface implements CoreListener { */ @Override public void soneUnlocked(Sone sone) { - Object tickerObject = lockedSonesTickerObjects.remove(sone); - if (tickerObject == null) { - return; - } lockedSonesNotification.remove(sone); - Ticker.getInstance().deregisterEvent(tickerObject); + Ticker.getInstance().deregisterEvent(lockedSonesTickerObjects.remove(sone)); } /**