Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the wrong use of setting fetcher in non-blocking thread #22

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading