Skip to content

Commit

Permalink
Merge pull request #104 from xpadev-net/fix/dated-comment-downloader
Browse files Browse the repository at this point in the history
[修正] 日付指定のコメントダウンロードが機能していなかったのを修正
  • Loading branch information
xpadev-net authored Aug 30, 2024
2 parents dbd5ae6 + f83c6fc commit 34712ef
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion electron/lib/niconico/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const downloadV3V1CustomComment = async (
for (const thread of option.threads) {
if (!thread.enable) continue;
const threadComments: FormattedComment[] = [];
const when = Math.floor(new Date(option.start).getTime() / 1000);
let when = Math.floor(new Date(option.start).getTime() / 1000);
const baseData = {
threadKey: metadata.nvComment.threadKey,
params: {
Expand Down Expand Up @@ -162,6 +162,14 @@ const downloadV3V1CustomComment = async (
const thread = (res as V1Raw)?.data?.threads[0];
if (!NiconiComments.typeGuard.v1.thread(thread))
throw new Error("failed to get comments");
const oldestCommentDate = new Date(
Math.min(
...thread.comments.map((comment) => {
return new Date(comment.postedAt).getTime();
}),
),
);
when = Math.floor(oldestCommentDate.getTime() / 1000);
threadComments.push(...convertV3ToFormatted([thread], userList));
if (option.end.type === "date") {
updateProgress(total * threadTotal, total * threadId + start - when);
Expand Down

0 comments on commit 34712ef

Please sign in to comment.