Skip to content

Commit

Permalink
Fix the wrong use of setting fetcher in reactive non-blocking thread
Browse files Browse the repository at this point in the history
Signed-off-by: JohnNiang <[email protected]>
  • Loading branch information
JohnNiang committed Jun 28, 2024
1 parent 94e34d1 commit de40c92
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/java/run/halo/umami/UmamiTrackerProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
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;
}

@Override
public Mono<Void> 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) {
Expand Down

0 comments on commit de40c92

Please sign in to comment.