From de40c9220809e35cdd2954e5ccdf592c4cbe9861 Mon Sep 17 00:00:00 2001 From: JohnNiang Date: Sat, 29 Jun 2024 00:06:43 +0800 Subject: [PATCH] Fix the wrong use of setting fetcher in reactive non-blocking thread Signed-off-by: JohnNiang --- .../java/run/halo/umami/UmamiTrackerProcessor.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/run/halo/umami/UmamiTrackerProcessor.java b/src/main/java/run/halo/umami/UmamiTrackerProcessor.java index 7e09138..b50bfcd 100644 --- a/src/main/java/run/halo/umami/UmamiTrackerProcessor.java +++ b/src/main/java/run/halo/umami/UmamiTrackerProcessor.java @@ -7,15 +7,15 @@ import org.thymeleaf.model.IModelFactory; import org.thymeleaf.processor.element.IElementModelStructureHandler; import reactor.core.publisher.Mono; -import run.halo.app.plugin.SettingFetcher; +import run.halo.app.plugin.ReactiveSettingFetcher; import run.halo.app.theme.dialect.TemplateHeadProcessor; @Component public class UmamiTrackerProcessor implements TemplateHeadProcessor { - private final SettingFetcher settingFetcher; + private final ReactiveSettingFetcher settingFetcher; - public UmamiTrackerProcessor(SettingFetcher settingFetcher) { + public UmamiTrackerProcessor(ReactiveSettingFetcher settingFetcher) { this.settingFetcher = settingFetcher; } @@ -23,11 +23,11 @@ public UmamiTrackerProcessor(SettingFetcher settingFetcher) { public Mono process(ITemplateContext context, IModel model, IElementModelStructureHandler structureHandler) { return settingFetcher.fetch("basic", BasicConfig.class) - .map(basicConfig -> { + .doOnNext(basicConfig -> { final IModelFactory modelFactory = context.getModelFactory(); model.add(modelFactory.createText(trackerScript(basicConfig.getWebsiteId(), basicConfig.endpoint, basicConfig.scriptName))); - return Mono.empty(); - }).orElse(Mono.empty()).then(); + }) + .then(); } private String trackerScript(String websiteId, String endpoint, String scriptName) {