favgroups: fix add to favgroup not working.
Fix the Add to Favgroup button not working when the user only has 1 favgroup.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import Rails from "@rails/ujs";
|
||||
|
||||
let FavoriteGroup = {};
|
||||
|
||||
FavoriteGroup.initialize_all = function() {
|
||||
@@ -23,8 +25,9 @@ FavoriteGroup.initialize_add_to_favgroup_dialog = function() {
|
||||
FavoriteGroup.open_favgroup_dialog = function(e) {
|
||||
if ($(".add-to-favgroup").length === 1) {
|
||||
// If the user only has one favorite group we don't need to ask which group to add the post to.
|
||||
$(".add-to-favgroup").click();
|
||||
} else if ($(".add-to-favgroup").length > 1) {
|
||||
let favgroup = $(".add-to-favgroup").get(0);
|
||||
Rails.fire(favgroup, "click");
|
||||
} else {
|
||||
$("#add-to-favgroup-dialog").dialog("open");
|
||||
}
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user