Skip to content

Commit

Permalink
SWC-6635: tailor cache invalidation to when deletion is successful
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin Jun Oh committed Apr 15, 2024
1 parent 56d3bd5 commit 064d3cc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,14 @@ public void onSuccess(Void result) {
// Go to entity's parent
Place gotoPlace = createDeletePlace();
getGlobalApplicationState().getPlaceChanger().goTo(gotoPlace);
KeyFactory keyFactory = keyFactoryProvider.getKeyFactory(
authenticationController.getCurrentUserAccessToken()
);
queryClient.invalidateQueries(
InvalidateQueryFilters.create(
keyFactory.getTrashCanItemsQueryKey()
)
);
}

@Override
Expand All @@ -2784,12 +2792,6 @@ public void onFailure(Throwable caught) {
}
}
);
KeyFactory keyFactory = keyFactoryProvider.getKeyFactory(
authenticationController.getCurrentUserAccessToken()
);
queryClient.invalidateQueries(
InvalidateQueryFilters.create(keyFactory.getTrashCanItemsQueryKey())
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2866,6 +2866,13 @@ public void testOnDeleteConfirmedPreFlightPassedDeleteFailed() {
verify(mockView).showErrorMessage(
DisplayConstants.ERROR_ENTITY_DELETE_FAILURE + error
);
QueryKey mockQueryKey = mock(QueryKey.class);
when(mockKeyFactory.getTrashCanItemsQueryKey()).thenReturn(mockQueryKey);
verify(mockKeyFactoryProvider, never()).getKeyFactory(anyString());
verify(mockKeyFactory, never()).getTrashCanItemsQueryKey();
verify(mockQueryClient, never()).invalidateQueries(
any(InvalidateQueryFilters.class)
);
}

@Test
Expand Down

0 comments on commit 064d3cc

Please sign in to comment.