Store Sone following time on following a Sone
[Sone.git] / src / main / java / net / pterodactylus / sone / database / memory / MemoryFriendDatabase.java
index 1802843..5ab1b28 100644 (file)
@@ -43,10 +43,14 @@ class MemoryFriendDatabase {
        }
 
        void addFriend(String localSoneId, String friendSoneId) {
+               loadFriends(localSoneId);
                lock.writeLock().lock();
                try {
                        if (soneFriends.put(localSoneId, friendSoneId)) {
                                configurationLoader.saveFriends(localSoneId, soneFriends.get(localSoneId));
+                               if (configurationLoader.getSoneFollowingTime(friendSoneId) == null) {
+                                       configurationLoader.setSoneFollowingTime(friendSoneId, System.currentTimeMillis());
+                               }
                        }
                } finally {
                        lock.writeLock().unlock();
@@ -54,6 +58,7 @@ class MemoryFriendDatabase {
        }
 
        void removeFriend(String localSoneId, String friendSoneId) {
+               loadFriends(localSoneId);
                lock.writeLock().lock();
                try {
                        if (soneFriends.remove(localSoneId, friendSoneId)) {