posts/show: fix flickering fav/unfav buttons.

This commit is contained in:
evazion
2018-08-13 02:35:24 -05:00
parent 7028417bfb
commit 72a37c2f94
3 changed files with 8 additions and 34 deletions

View File

@@ -3,30 +3,6 @@ import Utility from './utility'
let Favorite = {}
Favorite.initialize_all = function() {
if ($("#c-posts").length) {
this.hide_or_show_add_to_favorites_link();
}
}
Favorite.hide_or_show_add_to_favorites_link = function() {
var current_user_id = Utility.meta("current-user-id");
if (current_user_id === "") {
$("#add-to-favorites").hide();
$("#remove-from-favorites").hide();
$("#add-fav-button").hide();
$("#remove-fav-button").hide();
return;
}
if ($("#image-container").length && $("#image-container").data("is-favorited") === true) {
$("#add-to-favorites").hide();
$("#add-fav-button").hide();
} else {
$("#remove-from-favorites").hide();
$("#remove-fav-button").hide();
}
}
Favorite.create = function(post_id) {
Post.notice_update("inc");
@@ -57,9 +33,5 @@ Favorite.destroy = function(post_id) {
});
}
$(document).ready(function() {
Favorite.initialize_all();
});
export default Favorite