import net.pterodactylus.sone.web.ajax.DeleteProfileFieldAjaxPage;
import net.pterodactylus.sone.web.ajax.DeleteReplyAjaxPage;
import net.pterodactylus.sone.web.ajax.DismissNotificationAjaxPage;
-import net.pterodactylus.sone.web.ajax.DistrustAjaxPage;
import net.pterodactylus.sone.web.ajax.EditAlbumAjaxPage;
import net.pterodactylus.sone.web.ajax.EditImageAjaxPage;
import net.pterodactylus.sone.web.ajax.EditProfileFieldAjaxPage;
import net.pterodactylus.sone.web.ajax.LockSoneAjaxPage;
import net.pterodactylus.sone.web.ajax.MarkAsKnownAjaxPage;
import net.pterodactylus.sone.web.ajax.MoveProfileFieldAjaxPage;
-import net.pterodactylus.sone.web.ajax.TrustAjaxPage;
import net.pterodactylus.sone.web.ajax.UnbookmarkAjaxPage;
import net.pterodactylus.sone.web.ajax.UnfollowSoneAjaxPage;
import net.pterodactylus.sone.web.ajax.UnlikeAjaxPage;
import net.pterodactylus.sone.web.ajax.UnlockSoneAjaxPage;
-import net.pterodactylus.sone.web.ajax.UntrustAjaxPage;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.sone.web.page.TemplateRenderer;
import net.pterodactylus.sone.web.pages.*;
private final Loaders loaders;
/** The notification manager. */
- private final NotificationManager notificationManager = new NotificationManager();
+ private final NotificationManager notificationManager;
/** The Sone plugin. */
private final SonePlugin sonePlugin;
private final MetricRegistry metricRegistry;
private final Translation translation;
- /** The “new Sone” notification. */
- private final ListNotification<Sone> newSoneNotification;
-
/** The “new post” notification. */
private final ListNotification<Post> newPostNotification;
ParserFilter parserFilter, ShortenFilter shortenFilter,
RenderFilter renderFilter,
LinkedElementRenderFilter linkedElementRenderFilter,
- PageToadletRegistry pageToadletRegistry, MetricRegistry metricRegistry, Translation translation, L10nFilter l10nFilter) {
+ PageToadletRegistry pageToadletRegistry, MetricRegistry metricRegistry, Translation translation, L10nFilter l10nFilter,
+ NotificationManager notificationManager) {
this.sonePlugin = sonePlugin;
this.loaders = loaders;
this.listNotificationFilter = listNotificationFilter;
this.metricRegistry = metricRegistry;
this.l10nFilter = l10nFilter;
this.translation = translation;
+ this.notificationManager = notificationManager;
formPassword = sonePlugin.pluginRespirator().getToadletContainer().getFormPassword();
soneTextParser = new SoneTextParser(getCore(), getCore());
templateContextFactory.addTemplateObject("formPassword", formPassword);
/* create notifications. */
- Template newSoneNotificationTemplate = loaders.loadTemplate("/templates/notify/newSoneNotification.html");
- newSoneNotification = new ListNotification<>("new-sone-notification", "sones", newSoneNotificationTemplate, false);
-
Template newPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html");
newPostNotification = new ListNotification<>("new-post-notification", "posts", newPostNotificationTemplate, false);
pageToadletRegistry.addPage(new UploadImagePage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new EditImagePage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new DeleteImagePage(this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new TrustPage(this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new DistrustPage(this, loaders, templateRenderer));
- pageToadletRegistry.addPage(new UntrustPage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new MarkAsKnownPage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new BookmarkPage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new UnbookmarkPage(this, loaders, templateRenderer));
pageToadletRegistry.addPage(new UnfollowSoneAjaxPage(this));
pageToadletRegistry.addPage(new EditAlbumAjaxPage(this));
pageToadletRegistry.addPage(new EditImageAjaxPage(this, parserFilter, shortenFilter, renderFilter));
- pageToadletRegistry.addPage(new TrustAjaxPage(this));
- pageToadletRegistry.addPage(new DistrustAjaxPage(this));
- pageToadletRegistry.addPage(new UntrustAjaxPage(this));
pageToadletRegistry.addPage(new LikeAjaxPage(this));
pageToadletRegistry.addPage(new UnlikeAjaxPage(this));
pageToadletRegistry.addPage(new GetLikesAjaxPage(this));
//
/**
- * Notifies the web interface that a new {@link Sone} was found.
- *
- * @param newSoneFoundEvent
- * The event
- */
- @Subscribe
- public void newSoneFound(NewSoneFoundEvent newSoneFoundEvent) {
- newSoneNotification.add(newSoneFoundEvent.getSone());
- if (!hasFirstStartNotification()) {
- notificationManager.addNotification(newSoneNotification);
- }
- }
-
- /**
* Notifies the web interface that a new {@link Post} was found.
*
* @param newPostFoundEvent
boolean isLocal = post.getSone().isLocal();
if (isLocal) {
localPostNotification.add(post);
- } else {
- newPostNotification.add(post);
}
if (!hasFirstStartNotification()) {
- notificationManager.addNotification(isLocal ? localPostNotification : newPostNotification);
+ if (isLocal) {
+ notificationManager.addNotification(localPostNotification);
+ }
if (!getMentionedSones(post.getText()).isEmpty() && !isLocal) {
mentionNotification.add(post);
notificationManager.addNotification(mentionNotification);
}
- } else {
- getCore().markPostKnown(post);
}
}
}
}
- /**
- * Notifies the web interface that a {@link Sone} was marked as known.
- *
- * @param markSoneKnownEvent
- * The event
- */
- @Subscribe
- public void markSoneKnown(MarkSoneKnownEvent markSoneKnownEvent) {
- newSoneNotification.remove(markSoneKnownEvent.getSone());
- }
-
@Subscribe
public void markPostKnown(MarkPostKnownEvent markPostKnownEvent) {
removePost(markPostKnownEvent.getPost());
}
@Subscribe
- public void soneRemoved(SoneRemovedEvent soneRemovedEvent) {
- newSoneNotification.remove(soneRemovedEvent.getSone());
- }
-
- @Subscribe
public void postRemoved(PostRemovedEvent postRemovedEvent) {
removePost(postRemovedEvent.getPost());
}