From 5643db6d2ccadc0aafa3b28cf91a0b766f979413 Mon Sep 17 00:00:00 2001 From: Moebius-Strip Date: Sun, 6 May 2018 09:45:55 -0400 Subject: [PATCH] Simplify favorites link JS Make use of the "is favorited" data to determine if the post is favorited instead of relying on the entire list of favorites. --- app/assets/javascripts/favorites.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/assets/javascripts/favorites.js b/app/assets/javascripts/favorites.js index 4a46a8bf2..a3d59af7b 100644 --- a/app/assets/javascripts/favorites.js +++ b/app/assets/javascripts/favorites.js @@ -8,7 +8,6 @@ } Danbooru.Favorite.hide_or_show_add_to_favorites_link = function() { - var favorites = Danbooru.meta("favorites"); var current_user_id = Danbooru.meta("current-user-id"); if (current_user_id == "") { $("#add-to-favorites").hide(); @@ -17,8 +16,7 @@ $("#remove-fav-button").hide(); return; } - var regexp = new RegExp("\\bfav:" + current_user_id + "\\b"); - if ((favorites != undefined) && (favorites.match(regexp))) { + if ($("#image-container").length && $("#image-container").data("is-favorited") == true) { $("#add-to-favorites").hide(); $("#add-fav-button").hide(); } else {