I added the following code with showOpLikes, but I have issues with it. Somehow it doesn’t show original post like counts right away. I only does this after click sort by likes and back to latest without sorting.
Interestingly, showLikes doesn’t have this issue.
<script>
var TopicListComponent = require('discourse/components/topic-list').default;
TopicListComponent.reopen({
showOpLikes: true
});
</script>
Here is a screenshot before clicking on sort by likes and going to latest:
I believe showOpLikes should only work when sorting by OP likes by visiting a URL like https://meta.discourse.org/latest?order=op_likes, otherwise the op_like_count isn’t included (showLikes, should work… but that’s the total for the entire topic).
You can see this in action by viewing https://meta.discourse.org/latest.json and https://meta.discourse.org/latest.json?order=op_likes… op_like_count is only available in that second link.
Well, it depends on the goals of the community I guess. Our posts represent math questions and problems, so we’d like to see the most liked ones, and I’m not sure including likes given to answers should be considered. Hm. I don’t know.
I believe that you need to add some javascript to add OP likes to the serializer. If you search “add to serializer” (perhaps without spaces) you should find some examples.