From 68dddbabee18efe390ae5f2a2a2012cfa8f0a036 Mon Sep 17 00:00:00 2001 From: r-ca Date: Mon, 29 Jan 2024 01:07:41 +0900 Subject: [PATCH] WIP --- .../common/LacertaApplyTagDialog.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java index a8261f8e..61fbdcdb 100644 --- a/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java +++ b/component/common/src/main/java/one/nem/lacerta/component/common/LacertaApplyTagDialog.java @@ -142,24 +142,22 @@ public class LacertaApplyTagDialog extends DialogFragment { return CompletableFuture.supplyAsync(() -> { ArrayList documentTagArrayList = new ArrayList<>(); - setRegisteredTagList().join(); - setAppliedTagList(documentId).join(); + setRegisteredTagList().thenRun(() -> setAppliedTagList(documentId)).thenAccept(Void -> { + logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); + logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); - logger.debug("getDocumentTagArrayList", "this.registeredTags.size(): " + this.registeredTags.size()); - logger.debug("getDocumentTagArrayList", "this.appliedTags.size(): " + this.appliedTags.size()); - - for (int i = 0; i < this.registeredTags.size(); i++) { - boolean isChecked = false; - for (int j = 0; j < this.appliedTags.size(); j++) { - if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { - isChecked = true; - break; + for (int i = 0; i < this.registeredTags.size(); i++) { + boolean isChecked = false; + for (int j = 0; j < this.appliedTags.size(); j++) { + if (this.registeredTags.get(i).getId().equals(this.appliedTags.get(j).getId())) { + isChecked = true; + break; + } } + documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( + new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); } - documentTagArrayList.add(new DocumentTagApplyTagDialogExtendedModel( - new DocumentTag(this.registeredTags.get(i).getId(), this.registeredTags.get(i).getName(), this.registeredTags.get(i).getColor()), isChecked)); - } - + }).join(); return documentTagArrayList; }); } @@ -167,7 +165,11 @@ public class LacertaApplyTagDialog extends DialogFragment { private CompletableFuture setAppliedTagList(String documentId) { return CompletableFuture.supplyAsync(() -> { lacertaLibrary.getAppliedTagList(documentId).thenAccept(documentTags -> { - this.appliedTags = documentTags; + if (documentTags == null) { + this.appliedTags = new ArrayList<>(); + } else { + this.appliedTags = documentTags; + } }); return null; });