From: David ‘Bombe’ Roden Date: Sat, 23 Oct 2010 11:23:38 +0000 (+0200) Subject: Persist likes replies over plugin restarts. X-Git-Tag: 0.1-RC1~64 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3896f8c0877d4f935fce8a9c8e4109cfeb3e7203;p=Sone.git Persist likes replies over plugin restarts. --- diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index a4b3569..8bf2cea 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -673,6 +673,17 @@ public class Core extends AbstractService { sone.addLikedPostId(likedPostId); } + /* load liked reply IDs. */ + int likedReplyIdCounter = 0; + while (true) { + String likedReplyIdPrefix = sonePrefix + "/LikedReplyId." + likedReplyIdCounter++; + String likedReplyId = configuration.getStringValue(likedReplyIdPrefix + "/ID").getValue(null); + if (likedReplyId == null) { + break; + } + sone.addLikedReplyId(likedReplyId); + } + sone.setModificationCounter(modificationCounter); addLocalSone(sone); } catch (MalformedURLException mue1) { @@ -774,6 +785,14 @@ public class Core extends AbstractService { } configuration.getStringValue(sonePrefix + "/LikedPostId." + likedPostIdCounter + "/ID").setValue(null); + /* write all liked replies. */ + int likedReplyIdCounter = 0; + for (String soneLikedReplyId : sone.getLikedReplyIds()) { + String likedReplyIdPrefix = sonePrefix + "/LikedReplyId." + likedReplyIdCounter++; + configuration.getStringValue(likedReplyIdPrefix + "/ID").setValue(soneLikedReplyId); + } + configuration.getStringValue(sonePrefix + "/LikedReplyId." + likedReplyIdCounter + "/ID").setValue(null); + } /* write null ID as terminator. */ configuration.getStringValue("Sone/Sone." + soneId + "/ID").setValue(null);