Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/posts/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const user = require('../user');
const utils = require('../utils');

module.exports = function (Posts) {
Posts.getPostsFromSet = async function (set, start, stop, uid, reverse) {
Posts.getPostsFromSet = async function ({ set, start, stop, uid, reverse = false }) {
const pids = await Posts.getPidsFromSet(set, start, stop, reverse);
const posts = await Posts.getPostsByPids(pids, uid);
return await user.blocks.filter(uid, posts);
Comment on lines +9 to 12

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing Posts.getPostsFromSet from positional args to a destructured options object is a breaking API change for any external consumers (e.g. plugins importing src/posts). It can also fail silently if a caller still passes the old (set, start, stop, uid, reverse) signature, because destructuring will yield undefined for set/start/... and then query the wrong sorted set. Consider keeping backwards compatibility by accepting both calling conventions (detect object vs non-object), or introducing a new method name for the options-object signature and leaving the existing one intact (with a deprecation path).

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -44,8 +44,8 @@ module.exports = function (Posts) {
const postIndex = utils.isNumber(indices[index]) ? parseInt(indices[index], 10) + 1 : null;

if (slug && postIndex) {
const index = postIndex === 1 ? '' : `/${postIndex}`;
return `/topic/${slug}${index}`;
const postIndexSuffix = postIndex === 1 ? '' : `/${postIndex}`;
return `/topic/${slug}${postIndexSuffix}`;
}
return null;
});
Expand Down
Loading