Skip to content

Commit 3978a18

Browse files
authored
Restart scheduler when viewer is added or removed (#697)
1 parent 811bfca commit 3978a18

7 files changed

Lines changed: 12 additions & 7 deletions

File tree

inventory-framework-api/src/main/java/me/devnatan/inventoryframework/pipeline/StandardPipelinePhases.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ private StandardPipelinePhases() {}
5959
*/
6060
public static final PipelinePhase INVALIDATION = new PipelinePhase("invalidation");
6161

62+
public static final PipelinePhase VIEWER_ADDED = new PipelinePhase("viewer-added");
63+
64+
public static final PipelinePhase VIEWER_REMOVED = new PipelinePhase("viewer-removed");
65+
6266
/**
6367
* Called during layout resolution phase before {@link #FIRST_RENDER} phase.
6468
* In this pipeline phase the pipeline interceptor subject is a {@link IFRenderContext}.

inventory-framework-core/src/main/java/me/devnatan/inventoryframework/component/PaginationImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ private CompletableFuture<List<?>> loadSourceForTheCurrentPage() {
140140
isLoading = true;
141141
simulateStateUpdate();
142142

143-
// TODO Do some error treatment here, even if we expect to the user to handle it
144143
return createProvidedNewSource().handle((result, exception) -> {
145144
if (exception != null) {
146145
debug("[Pagination] An error occurred on data source computation: %s", exception.getMessage());

inventory-framework-core/src/main/java/me/devnatan/inventoryframework/pipeline/ScheduledUpdateAfterRenderInterceptor.java renamed to inventory-framework-core/src/main/java/me/devnatan/inventoryframework/pipeline/ScheduledUpdateStartInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import me.devnatan.inventoryframework.context.IFRenderContext;
99
import me.devnatan.inventoryframework.internal.Job;
1010

11-
public final class ScheduledUpdateAfterRenderInterceptor implements PipelineInterceptor<VirtualView> {
11+
public final class ScheduledUpdateStartInterceptor implements PipelineInterceptor<VirtualView> {
1212

1313
@Override
1414
public void intercept(PipelineContext<VirtualView> pipeline, VirtualView subject) {

inventory-framework-core/src/main/java/me/devnatan/inventoryframework/pipeline/ScheduledUpdateAfterCloseInterceptor.java renamed to inventory-framework-core/src/main/java/me/devnatan/inventoryframework/pipeline/ScheduledUpdateStopInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import me.devnatan.inventoryframework.context.IFCloseContext;
66
import me.devnatan.inventoryframework.context.IFContext;
77

8-
public final class ScheduledUpdateAfterCloseInterceptor implements PipelineInterceptor<VirtualView> {
8+
public final class ScheduledUpdateStopInterceptor implements PipelineInterceptor<VirtualView> {
99

1010
@Override
1111
public void intercept(PipelineContext<VirtualView> pipeline, VirtualView subject) {

inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/PlatformView.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
import me.devnatan.inventoryframework.pipeline.PlatformOpenInterceptor;
3535
import me.devnatan.inventoryframework.pipeline.PlatformRenderInterceptor;
3636
import me.devnatan.inventoryframework.pipeline.PlatformUpdateHandlerInterceptor;
37-
import me.devnatan.inventoryframework.pipeline.ScheduledUpdateAfterCloseInterceptor;
38-
import me.devnatan.inventoryframework.pipeline.ScheduledUpdateAfterRenderInterceptor;
37+
import me.devnatan.inventoryframework.pipeline.ScheduledUpdateStartInterceptor;
38+
import me.devnatan.inventoryframework.pipeline.ScheduledUpdateStopInterceptor;
3939
import me.devnatan.inventoryframework.pipeline.StandardPipelinePhases;
4040
import me.devnatan.inventoryframework.pipeline.UpdateInterceptor;
4141
import me.devnatan.inventoryframework.pipeline.ViewerLastInteractionTrackerInterceptor;
@@ -601,11 +601,11 @@ final void internalInitialization(IFViewFrame<?, ?> framework) {
601601
pipeline.intercept(StandardPipelinePhases.FIRST_RENDER, new LayoutRenderInterceptor());
602602
pipeline.intercept(StandardPipelinePhases.FIRST_RENDER, new AvailableSlotInterceptor());
603603
pipeline.intercept(StandardPipelinePhases.FIRST_RENDER, new FirstRenderInterceptor());
604-
pipeline.intercept(StandardPipelinePhases.FIRST_RENDER, new ScheduledUpdateAfterRenderInterceptor());
604+
pipeline.intercept(StandardPipelinePhases.VIEWER_ADDED, new ScheduledUpdateStartInterceptor());
605+
pipeline.intercept(StandardPipelinePhases.VIEWER_REMOVED, new ScheduledUpdateStopInterceptor());
605606
pipeline.intercept(StandardPipelinePhases.UPDATE, new PlatformUpdateHandlerInterceptor());
606607
pipeline.intercept(StandardPipelinePhases.UPDATE, new UpdateInterceptor());
607608
pipeline.intercept(StandardPipelinePhases.CLOSE, new PlatformCloseInterceptor());
608-
pipeline.intercept(StandardPipelinePhases.CLOSE, new ScheduledUpdateAfterCloseInterceptor());
609609
pipeline.intercept(StandardPipelinePhases.CLOSE, new ContextInvalidationOnCloseInterceptor());
610610
pipeline.intercept(StandardPipelinePhases.CLICK, new ViewerLastInteractionTrackerInterceptor());
611611
pipeline.intercept(StandardPipelinePhases.CLICK, new ComponentClickHandlerCallInterceptor());

inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/pipeline/ContextInvalidationOnCloseInterceptor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void intercept(PipelineContext<VirtualView> pipeline, VirtualView subject
2323
final PlatformView root = (PlatformView) context.getRoot();
2424
final Viewer viewer = context.getViewer();
2525
root.onViewerRemoved(context.getParent(), viewer.getPlatformInstance());
26+
root.getPipeline().execute(StandardPipelinePhases.VIEWER_REMOVED, subject);
2627
root.removeAndTryInvalidateContext(viewer, context);
2728
}
2829
}

inventory-framework-platform/src/main/java/me/devnatan/inventoryframework/pipeline/PlatformOpenInterceptor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ IFRenderContext createRenderContext(IFOpenContext openContext) {
9090
if (!viewer.isTransitioning()) viewer.setActiveContext(renderContext);
9191
// TODO Pass viewer object as parameter instead
9292
root.onViewerAdded(renderContext, viewer.getPlatformInstance(), renderContext.getInitialData());
93+
root.getPipeline().execute(StandardPipelinePhases.VIEWER_ADDED, renderContext);
9394
renderContext.addViewer(viewer);
9495
}
9596

0 commit comments

Comments
 (0)