Skip to content

Commit

Permalink
Merge pull request #462 from nextcloud/fix-categories-initial-state
Browse files Browse the repository at this point in the history
Fix favorite category states
  • Loading branch information
Julien Veyssier authored Sep 30, 2020
2 parents 0d37b84 + 718c469 commit 0c93cd6
Showing 1 changed file with 10 additions and 3 deletions.
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

0 comments on commit 0c93cd6

Please sign in to comment.