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.
This commit is contained in:
Moebius-Strip
2018-05-06 09:45:55 -04:00
committed by Albert Yi
parent 3b8a1703ff
commit 68e48e3b81

View File

@@ -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 {