Skip to content

Commit

Permalink
Fix bug brought by Discourse 2.9.0.beta3
Browse files Browse the repository at this point in the history
  • Loading branch information
freemdict committed Mar 27, 2022
1 parent 84c5631 commit 3f337c0
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions javascripts/discourse/initializers/post-views-counter.js.es6
Expand Up @@ -6,18 +6,15 @@ function initWithApi(api) {
api.reopenWidget("post-meta-data", {
html(attrs) {
const infos = this._super(...arguments);

const postInfosIdx = infos.findIndex(i => {
return i.properties && i.properties.className == "post-infos";
});

if (postInfosIdx < 0) return infos;

const childs = infos[postInfosIdx].children || [];
const postDateIdx = childs.findIndex(i => {
return i.properties && i.properties.className == "post-info post-date";
return Object.getPrototypeOf(i) && Object.getPrototypeOf(i).tagName && Object.getPrototypeOf(i).tagName == "div.post-info.post-date";
});

if (postDateIdx < 0) return infos;

const reads = attrs.readCount || 0;
Expand All @@ -28,9 +25,7 @@ function initWithApi(api) {
},
[reads, iconNode("far-eye")]
);

childs.insertAt(postDateIdx, views);

infos[postInfosIdx].children = childs;

return infos;
Expand Down

0 comments on commit 3f337c0

Please sign in to comment.