Save on category share

This commit is contained in:
crschnick 2024-04-21 01:28:57 +00:00
parent 51f7e3f4f5
commit 73bc99b3c6
2 changed files with 18 additions and 11 deletions

View file

@ -107,17 +107,7 @@ public class StoreCategoryWrapper {
});
share.addListener((observable, oldValue, newValue) -> {
category.setShare(newValue);
DataStoreCategory p = category;
if (newValue) {
while ((p = DataStorage.get()
.getStoreCategoryIfPresent(p.getParentCategory())
.orElse(null))
!= null) {
p.setShare(true);
}
}
DataStorage.get().shareCategory(category, newValue);
});
}

View file

@ -314,6 +314,23 @@ public abstract class DataStorage {
saveAsync();
}
public void shareCategory(DataStoreCategory category, boolean share) {
category.setShare(share);
DataStoreCategory p = category;
if (share) {
while ((p = DataStorage.get()
.getStoreCategoryIfPresent(p.getParentCategory())
.orElse(null))
!= null) {
p.setShare(true);
}
}
// Update git remote if needed
DataStorage.get().saveAsync();
}
public void updateCategory(DataStoreEntry entry, DataStoreCategory newCategory) {
if (getStoreCategoryIfPresent(entry.getUuid())
.map(category -> category.equals(newCategory))