Skip to content

Commit

Permalink
changed to session storaged (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioG70 authored Dec 19, 2024
1 parent 6e1d2b2 commit e5f30a0
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,30 +159,30 @@ public void updateExcludedInfo() {
+ " " + messages.manageDatabaseSearchAllExcludedPrivacy(this.notSearchable))));
}

public void writeSelectedObjectsToLocalStorage() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
public void writeSelectedObjectsToSessionStorage() {
Storage sessionStorage = Storage.getSessionStorageIfSupported();
if (sessionStorage != null) {
SelectedItems<ViewerDatabase> selectedItems = this.list.getSelected();
if (selectedItems instanceof SelectedItemsList<?>) {
localStorage.setItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION,
sessionStorage.setItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION,
String.join(",", ((SelectedItemsList<ViewerDatabase>) selectedItems).getIds()));
} else if (selectedItems instanceof SelectedItemsFilter<?>) {
localStorage.setItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION,
sessionStorage.setItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION,
ViewerConstants.SEARCH_ALL_SELECTED_ALL);
}
}
}

private void confirmHandler() {
this.writeSelectedObjectsToLocalStorage();
this.writeSelectedObjectsToSessionStorage();
this.doParentSearch();
this.hide();
}

private void cancelHandler() {
Storage localStorage = Storage.getLocalStorageIfSupported();
if (localStorage != null) {
String uuidsString = localStorage.getItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION);
Storage sessionStorage = Storage.getSessionStorageIfSupported();
if (sessionStorage != null) {
String uuidsString = sessionStorage.getItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION);
if (uuidsString != null && !uuidsString.equals(ViewerConstants.SEARCH_ALL_SELECTED_ALL)) {
List<String> selectedUUIDs = new ArrayList<>();
if (!uuidsString.isEmpty()) {
Expand All @@ -201,11 +201,11 @@ private void clearHandler() {
}

private void doParentSearch() {
Storage localStorage = Storage.getLocalStorageIfSupported();
Storage sessionStorage = Storage.getSessionStorageIfSupported();
List<String> selectedUUIDs = null;
boolean selectedAll = false;
if (localStorage != null) {
String uuidsString = localStorage.getItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION);
if (sessionStorage != null) {
String uuidsString = sessionStorage.getItem(ViewerConstants.LOCAL_STORAGE_SEARCH_ALL_SELECTION);
if (uuidsString != null) {
if (uuidsString.equals(ViewerConstants.SEARCH_ALL_SELECTED_ALL)) {
selectedAll = true;
Expand Down

0 comments on commit e5f30a0

Please sign in to comment.