Skip to content

Commit

Permalink
feat: comment limit
Browse files Browse the repository at this point in the history
(cherry picked from commit a46c4b2)
  • Loading branch information
xpadev-net committed Mar 16, 2023
1 parent 360789e commit 97ccfc8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/@types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type BaseConfig = {
letterSpacing: number;
scriptCharOffset: number;
plugins: IPluginConstructor[];
commentLimit: number | undefined;
hideCommentOrder: "asc" | "desc";
};

export type Config = Partial<BaseConfig>;
2 changes: 2 additions & 0 deletions src/definition/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ const initConfig = () => {
},
letterSpacing: 1,
scriptCharOffset: 0.12,
commentLimit: undefined,
hideCommentOrder: "asc",
};
};

Expand Down
11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,16 @@ class NiconiComments {
}

if (timelineRange) {
for (const comment of timelineRange) {
const targetComment = (() => {
if (config.commentLimit === undefined) {
return timelineRange;
}
if (config.hideCommentOrder === "asc") {
return timelineRange.slice(-config.commentLimit);
}
return timelineRange.slice(0, config.commentLimit);
})();
for (const comment of targetComment) {
if (comment.invisible) {
continue;
}
Expand Down

0 comments on commit 97ccfc8

Please sign in to comment.