diff --git a/src/main/java/org/cryptomator/common/vaults/Vault.java b/src/main/java/org/cryptomator/common/vaults/Vault.java
index 812eed8a0..24418dc7e 100644
--- a/src/main/java/org/cryptomator/common/vaults/Vault.java
+++ b/src/main/java/org/cryptomator/common/vaults/Vault.java
@@ -266,7 +266,7 @@ public class Vault {
private void consumeVaultEvent(FilesystemEvent e) {
fileSystemEventAggregator.put(this, e);
- notificationManager.tryAddEvent(e);
+ notificationManager.tryAddEvent(this, e);
}
// ******************************************************************************
diff --git a/src/main/java/org/cryptomator/event/NotificationManager.java b/src/main/java/org/cryptomator/event/NotificationManager.java
index 7cd22fa70..c2b0e4158 100644
--- a/src/main/java/org/cryptomator/event/NotificationManager.java
+++ b/src/main/java/org/cryptomator/event/NotificationManager.java
@@ -2,6 +2,7 @@ package org.cryptomator.event;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
+import org.cryptomator.common.vaults.Vault;
import org.cryptomator.cryptofs.event.BrokenFileNodeEvent;
import org.cryptomator.cryptofs.event.FilesystemEvent;
@@ -16,12 +17,12 @@ import java.util.Queue;
/**
* Manager for notifications.
*
- * To add (filesystem) events, use method {@link #tryAddEvent(FilesystemEvent)}. If the input event is eligible, it is added to an internal queue.
- * An event is eligible, if
- *
- * the event should trigger a notification and
- * it is not added within the last {@value DEBOUNCE_THRESHOLD_SECONDS} seconds
- *
+ * To add (filesystem) events, use method {@link #tryAddEvent(Vault, FilesystemEvent)}. If the input event is eligible, it is added to an internal queue.
+ * An event is eligible, if
+ *
+ * the event should trigger a notification and
+ * it is not added within the last {@value DEBOUNCE_THRESHOLD_SECONDS} seconds
+ *
*
*/
@Singleton
@@ -30,7 +31,7 @@ public class NotificationManager {
private static final int DEBOUNCE_THRESHOLD_SECONDS = 5;
Cache eventCache;
- Queue eventsRequiringNotification;
+ Queue eventsRequiringNotification;
@Inject
public NotificationManager() {
@@ -38,30 +39,31 @@ public class NotificationManager {
eventsRequiringNotification = new ArrayDeque<>();
}
- public boolean tryAddEvent(FilesystemEvent e) {
+ public boolean tryAddEvent(Vault v, FilesystemEvent e) {
var notRecentlyAdded = switch (e) {
case BrokenFileNodeEvent bfne -> isRecent(bfne.ciphertextPath(), bfne);
default -> false;
};
- if(notRecentlyAdded) {
+ if (notRecentlyAdded) {
synchronized (this) {
- eventsRequiringNotification.add(e);
+ eventsRequiringNotification.add(new VaultEvent(v, e));
}
}
return notRecentlyAdded;
}
boolean isRecent(Path key, FilesystemEvent e) {
- var cacheElement = eventCache.get(key, _ -> e);
+ var cacheElement = eventCache.get(key, _ -> e);
return cacheElement == e;
}
/**
* Clones all events requiring a notification to the target list and clears afterward the notification manager queue
+ *
* @param target list the queue is cloned to
* @return {@code true}, if elements were copied
*/
- public boolean cloneTo(List target) {
+ public boolean cloneTo(List target) {
synchronized (this) {
var result = target.addAll(eventsRequiringNotification);
eventsRequiringNotification.clear();
diff --git a/src/main/java/org/cryptomator/event/VaultEvent.java b/src/main/java/org/cryptomator/event/VaultEvent.java
index 8b31747cf..1095c812b 100644
--- a/src/main/java/org/cryptomator/event/VaultEvent.java
+++ b/src/main/java/org/cryptomator/event/VaultEvent.java
@@ -3,25 +3,6 @@ package org.cryptomator.event;
import org.cryptomator.common.vaults.Vault;
import org.cryptomator.cryptofs.event.FilesystemEvent;
-import java.time.Instant;
+public record VaultEvent(Vault v, FilesystemEvent actualEvent) {
-public record VaultEvent(Vault v, FilesystemEvent actualEvent, int count) implements Comparable {
-
- public VaultEvent(Vault v, FilesystemEvent actualEvent) {
- this(v, actualEvent, 1);
- }
-
- @Override
- public int compareTo(VaultEvent other) {
- var timeResult = actualEvent.getTimestamp().compareTo(other.actualEvent().getTimestamp());
- if(timeResult != 0) {
- return timeResult;
- } else {
- return this.equals(other) ? 0 : this.actualEvent.getClass().getName().compareTo(other.actualEvent.getClass().getName());
- }
- }
-
- public VaultEvent incrementCount(FilesystemEvent update) {
- return new VaultEvent(v, update, count+1);
- }
}
diff --git a/src/main/java/org/cryptomator/ui/fxapp/FxNotificationRadar.java b/src/main/java/org/cryptomator/ui/fxapp/FxNotificationRadar.java
index d7aadb103..2e5bcc933 100644
--- a/src/main/java/org/cryptomator/ui/fxapp/FxNotificationRadar.java
+++ b/src/main/java/org/cryptomator/ui/fxapp/FxNotificationRadar.java
@@ -1,7 +1,7 @@
package org.cryptomator.ui.fxapp;
-import org.cryptomator.cryptofs.event.FilesystemEvent;
import org.cryptomator.event.NotificationManager;
+import org.cryptomator.event.VaultEvent;
import javax.inject.Inject;
import javafx.application.Platform;
@@ -19,7 +19,7 @@ public class FxNotificationRadar {
private final NotificationManager notificationManager;
private final ScheduledExecutorService scheduler;
private final FxApplicationWindows applicationWindows;
- private final ObservableList eventsRequiringNotification;
+ private final ObservableList eventsRequiringNotification;
@Inject
public FxNotificationRadar(NotificationManager notificationManager, ScheduledExecutorService scheduler, FxApplicationWindows applicationWindows) {
@@ -45,7 +45,7 @@ public class FxNotificationRadar {
}
- public ObservableList getEventsRequiringNotification() {
+ public ObservableList getEventsRequiringNotification() {
return eventsRequiringNotification;
}
diff --git a/src/main/java/org/cryptomator/ui/notification/NotificationController.java b/src/main/java/org/cryptomator/ui/notification/NotificationController.java
index 8b9dd747d..e93d1863e 100644
--- a/src/main/java/org/cryptomator/ui/notification/NotificationController.java
+++ b/src/main/java/org/cryptomator/ui/notification/NotificationController.java
@@ -1,6 +1,7 @@
package org.cryptomator.ui.notification;
import org.cryptomator.cryptofs.event.FilesystemEvent;
+import org.cryptomator.event.VaultEvent;
import org.cryptomator.ui.common.FxController;
import org.cryptomator.ui.fxapp.FxNotificationRadar;
@@ -25,10 +26,10 @@ import java.util.concurrent.ExecutorService;
public class NotificationController implements FxController {
private final Stage window;
- private final SimpleListProperty notificationsProp;
+ private final SimpleListProperty notificationsProp;
private final IntegerProperty selectionIndex;
private final ObservableStringValue paging;
- private final ObjectProperty selectedEvent;
+ private final ObjectProperty selectedEvent;
private final StringProperty message;
private final StringProperty description;
private final StringProperty actionText;
@@ -55,8 +56,8 @@ public class NotificationController implements FxController {
}
//TODO: Translations!
- private void adjustTexts(ObservableValue extends FilesystemEvent> observable, FilesystemEvent oldEvent, FilesystemEvent newEvent) {
- switch (newEvent) {
+ private void adjustTexts(ObservableValue extends VaultEvent> observable, VaultEvent oldEvent, VaultEvent newEvent) {
+ switch (newEvent.actualEvent()) {
default -> {
message.set("NO CONTENT");
description.set("IF YOU SEE THIS MESSAGE, PLEASE CONTACT THE DEVELOPERS OF CRYPTOMATOR ABOUT A BUG IN THE NOTIFICATION DISPLAY");
@@ -69,7 +70,7 @@ public class NotificationController implements FxController {
public void handleButtonAction() {
try {
var ev = selectedEvent.get();
- switch (ev) {
+ switch (ev.actualEvent()) {
//TODO: executorService.submit(callback.action());
default -> {
} //normally nothing