Skip to content

Commit

Permalink
fix: do not deactivate expanded item keys (#19006) (#19047)
Browse files Browse the repository at this point in the history
* fix: do not deactivate expanded item keys (#19006)

* if unique key provider exists, remove items normally
  • Loading branch information
tepi committed Apr 3, 2024
1 parent 43447ae commit 30f8aaf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Expand Up @@ -79,6 +79,8 @@ public class HierarchicalCommunicationController<T> implements Serializable {
// Update ids that have been confirmed since the last flush
private final HashSet<Integer> confirmedUpdates = new HashSet<>();

private boolean hasUniqueKeyProviderSupplier;

/**
* Constructs communication controller with support for hierarchical data
* structure.
Expand Down Expand Up @@ -319,7 +321,8 @@ private void doUnregister(Integer updateId) {
if (passivated != null) {
passivated.forEach(key -> {
T item = keyMapper.get(key);
if (item != null) {
if (item != null && (hasUniqueKeyProviderSupplier
|| !mapper.isExpanded(item))) {
dataGenerator.destroyData(item);
keyMapper.remove(item);
}
Expand All @@ -341,6 +344,11 @@ public JsonValue generateJson(T item) {
return json;
}

public void setHasUniqueKeyProviderSupplier(
boolean hasUniqueKeyProviderSupplier) {
this.hasUniqueKeyProviderSupplier = hasUniqueKeyProviderSupplier;
}

private static final void withMissing(Range expected, Range actual,
Consumer<Range> action) {
Range[] partition = expected.partitionWith(actual);
Expand Down
Expand Up @@ -196,7 +196,8 @@ parentKey, getKeyMapper(), mapper,
.startUpdate(getDataProviderSize()),
(pkey, range) -> mapper.fetchChildItems(
getKeyMapper().get(pkey), range)));

controller.setHasUniqueKeyProviderSupplier(
uniqueKeyProviderSupplier.get() != null);
Range range = computeRequestedRange(start, length);
controller.setRequestRange(range.getStart(), range.length());
requestFlush(controller);
Expand Down

0 comments on commit 30f8aaf

Please sign in to comment.