🐛 Fix follow and unfollow functions
[Sone.git] / src / main / resources / static / javascript / sone.js
index 8e599ae..8798aae 100644 (file)
@@ -685,34 +685,38 @@ function ajaxifySone(soneElement) {
        });
 }
 
-const followSone = function(soneId) {
-       const followElement = this;
-       ajaxGet("followSone.ajax", { "sone": soneId, "formPassword": getFormPassword() }, function() {
-               $(followElement).addClass("hidden");
-               $(followElement).parent().find(".unfollow").removeClass("hidden");
-               sone.find(".sone-menu").each(function() {
-                       if (getMenuSone(this) === soneId) {
-                               $(".follow", this).toggleClass("hidden", true);
-                               $(".unfollow", this).toggleClass("hidden", false);
-                       }
+function followSone(soneId) {
+       return function() {
+               const followElement = this;
+               ajaxGet("followSone.ajax", {"sone": soneId, "formPassword": getFormPassword()}, function () {
+                       $(followElement).addClass("hidden");
+                       $(followElement).parent().find(".unfollow").removeClass("hidden");
+                       sone.find(".sone-menu").each(function () {
+                               if (getMenuSone(this) === soneId) {
+                                       $(".follow", this).toggleClass("hidden", true);
+                                       $(".unfollow", this).toggleClass("hidden", false);
+                               }
+                       });
                });
-       });
-       return false;
-};
+               return false;
+       }
+}
 
-const unfollowSone = function (soneId) {
-       const unfollowElement = this;
-       ajaxGet("unfollowSone.ajax", {"sone": soneId, "formPassword": getFormPassword()}, function () {
-               $(unfollowElement).addClass("hidden");
-               $(unfollowElement).parent().find(".follow").removeClass("hidden");
-               sone.find(".sone-menu").each(function () {
-                       if (getMenuSone(this) === soneId) {
-                               $(".follow", this).toggleClass("hidden", false);
-                               $(".unfollow", this).toggleClass("hidden", true);
-                       }
+function unfollowSone(soneId) {
+       return function() {
+               const unfollowElement = this;
+               ajaxGet("unfollowSone.ajax", {"sone": soneId, "formPassword": getFormPassword()}, function () {
+                       $(unfollowElement).addClass("hidden");
+                       $(unfollowElement).parent().find(".follow").removeClass("hidden");
+                       sone.find(".sone-menu").each(function () {
+                               if (getMenuSone(this) === soneId) {
+                                       $(".follow", this).toggleClass("hidden", false);
+                                       $(".unfollow", this).toggleClass("hidden", true);
+                               }
+                       });
                });
-       });
-       return false;
+               return false;
+       }
 };
 
 /**
@@ -1273,7 +1277,7 @@ function getCurrentSoneId() {
 /**
  * Returns the content of the page-id attribute.
  *
- * @returns The page ID
+ * @returns String The page ID
  */
 function getPageId() {
        return sone.find(".page-id").text();
@@ -1617,7 +1621,7 @@ function updatePostTimes(postIds) {
 /**
  * Updates the time of the reply with the given ID.
  *
- * @param postId
+ * @param replyId
  *            The ID of the reply to update
  * @param timeText
  *            The text of the time to show
@@ -1638,7 +1642,7 @@ function updateReplyTime(replyId, timeText, refreshTime, tooltip) {
 /**
  * Requests new rendered times for the posts with the given IDs.
  *
- * @param postIds
+ * @param replyIds
  *            Comma-separated post IDs
  */
 function updateReplyTimes(replyIds) {