Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix favorite category states #462

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/favoritesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@ FavoritesController.prototype = {
for (var i=0; i < favorites.length; i++) {
var token = sharedCategories[favorites[i].category] || null;

that.addFavoriteMap(favorites[i], true, false, token);
const enableCategory = that.optionsController.enabledFavoriteCategories.includes(favorites[i].category)
that.addFavoriteMap(favorites[i], enableCategory, false, token);
}

that.updateCategoryCounters();
Expand Down Expand Up @@ -823,7 +824,6 @@ FavoritesController.prototype = {
that.addFavoriteMap(response, true, true);
that.updateCategoryCounters();
// show edition popup
console.log(response);
that.openEditionPopup(response.id);
}).always(function (response) {
$('#navigation-favorites').removeClass('icon-loading-small');
Expand All @@ -839,7 +839,7 @@ FavoritesController.prototype = {
var cat = fav.category;
if (!this.categoryLayers.hasOwnProperty(cat)) {
this.addCategory(cat, enableCategory, shareToken);
if (enableCategory) {
if (enableCategory && fromUserAction) {
this.saveEnabledCategories();
}
}
Expand Down Expand Up @@ -1170,7 +1170,14 @@ FavoritesController.prototype = {
if (!this.categoryLayers.hasOwnProperty(newCategory)) {
this.addCategory(newCategory, true);
shouldSaveCategories = true;
} else {
// enable category if it's not
if (!this.map.hasLayer(this.categoryLayers[newCategory])) {
this.toggleCategory(newCategory)
shouldSaveCategories = true;
}
}

if (shouldSaveCategories) {
this.saveEnabledCategories();
}
Expand Down