Merge branch 'next' into edit-wot-trust
[Sone.git] / src / main / java / net / pterodactylus / sone / web / WebInterface.java
index 2ea755b..c1c0653 100644 (file)
@@ -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));
        }
 
        /**