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: new tags showing null post count on theme #7049

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ public Result reconcile(Request request) {
String newPattern = tagPermalinkPolicy.pattern();
annotations.put(Constant.PERMALINK_PATTERN_ANNO, newPattern);

String permalink = tagPermalinkPolicy.permalink(tag);
var status = tag.getStatusOrDefault();
String permalink = tagPermalinkPolicy.permalink(tag);
status.setPermalink(permalink);

if (status.getPostCount() == null) {
status.setPostCount(0);
}
if (status.getVisiblePostCount() == null) {
status.setVisiblePostCount(0);
}

// Update the observed version.
status.setObservedVersion(tag.getMetadata().getVersion() + 1);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package run.halo.app.theme.finders.vo;

import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;

import lombok.Builder;
import lombok.Value;
import run.halo.app.core.extension.content.Tag;
Expand Down Expand Up @@ -33,7 +35,7 @@ public static TagVo from(Tag tag) {
.metadata(tag.getMetadata())
.spec(spec)
.status(status)
.postCount(tag.getStatusOrDefault().getVisiblePostCount())
.postCount(defaultIfNull(status.getVisiblePostCount(), 0))
.build();
}
}
Loading