diff --git a/src/main/java/ch/climbd/newsfeed/data/NewsEntry.java b/src/main/java/ch/climbd/newsfeed/data/NewsEntry.java index 1920027..559b468 100644 --- a/src/main/java/ch/climbd/newsfeed/data/NewsEntry.java +++ b/src/main/java/ch/climbd/newsfeed/data/NewsEntry.java @@ -22,6 +22,7 @@ public class NewsEntry { private Integer views = 0; private String language = "undefined"; + private boolean deleted = false; public NewsEntry() { } @@ -109,6 +110,14 @@ public void setLanguage(String language) { this.language = language; } + public boolean isDeleted() { + return deleted; + } + + public void delete() { + this.deleted = true; + } + public String getDomainWithProtocol() { if (!link.isEmpty()) { var start = link.indexOf("://") + 3; diff --git a/src/main/java/ch/climbd/newsfeed/views/components/NewsItemComponent.java b/src/main/java/ch/climbd/newsfeed/views/components/NewsItemComponent.java index 8c269be..85cbb13 100644 --- a/src/main/java/ch/climbd/newsfeed/views/components/NewsItemComponent.java +++ b/src/main/java/ch/climbd/newsfeed/views/components/NewsItemComponent.java @@ -48,6 +48,9 @@ public VerticalLayout createNewsItem(List items) { var verticalLayout = new VerticalLayout(); var index = 0; for (var item : items) { + if (item.isDeleted()) { + continue; + } index++; HorizontalLayout row = buildNewsItem(index, item, verticalLayout); if (row == null) continue; @@ -121,7 +124,9 @@ public HorizontalLayout buildNewsItem(int index, NewsEntry item, VerticalLayout delete.setSize("15px"); delete.setTooltipText("Delete"); delete.addClickListener((ComponentEventListener>) iconClickEvent -> { - mongo.delete(item); + LOG.info("Delete: " + item.getTitle()); + item.delete(); + mongo.update(item); UI.getCurrent().getPage().reload(); });