Skip to content

Commit

Permalink
Switch to "mark as deleted"
Browse files Browse the repository at this point in the history
  • Loading branch information
mithandir committed Jun 18, 2024
1 parent a148f1a commit 5fe66b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/ch/climbd/newsfeed/data/NewsEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class NewsEntry {

private Integer views = 0;
private String language = "undefined";
private boolean deleted = false;

public NewsEntry() {
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public VerticalLayout createNewsItem(List<NewsEntry> 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;
Expand Down Expand Up @@ -121,7 +124,9 @@ public HorizontalLayout buildNewsItem(int index, NewsEntry item, VerticalLayout
delete.setSize("15px");
delete.setTooltipText("Delete");
delete.addClickListener((ComponentEventListener<ClickEvent<Icon>>) iconClickEvent -> {
mongo.delete(item);
LOG.info("Delete: " + item.getTitle());
item.delete();
mongo.update(item);
UI.getCurrent().getPage().reload();
});

Expand Down

0 comments on commit 5fe66b9

Please sign in to comment.