Skip to content

Commit

Permalink
feature(proto): Add comment_id to commentSectionParams (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
gurumnyang authored Jul 24, 2024
1 parent a352dde commit a5f6209
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export declare namespace $.youtube.GetCommentsSectionParams.Params {
videoId: string;
sortBy: number;
type: number;
commentId?: string;
}
}

Expand All @@ -31,6 +32,7 @@ export function getDefaultValue(): $.youtube.GetCommentsSectionParams.Params.Opt
videoId: "",
sortBy: 0,
type: 0,
commentId: undefined,
};
}

Expand All @@ -46,6 +48,7 @@ export function encodeJson(value: $.youtube.GetCommentsSectionParams.Params.Opti
if (value.videoId !== undefined) result.videoId = tsValueToJsonValueFns.string(value.videoId);
if (value.sortBy !== undefined) result.sortBy = tsValueToJsonValueFns.int32(value.sortBy);
if (value.type !== undefined) result.type = tsValueToJsonValueFns.int32(value.type);
if (value.commentId !== undefined) result.commentId = tsValueToJsonValueFns.string(value.commentId);
return result;
}

Expand All @@ -54,6 +57,7 @@ export function decodeJson(value: any): $.youtube.GetCommentsSectionParams.Param
if (value.videoId !== undefined) result.videoId = jsonValueToTsValueFns.string(value.videoId);
if (value.sortBy !== undefined) result.sortBy = jsonValueToTsValueFns.int32(value.sortBy);
if (value.type !== undefined) result.type = jsonValueToTsValueFns.int32(value.type);
if (value.commentId !== undefined) result.commentId = jsonValueToTsValueFns.string(value.commentId);
return result;
}

Expand All @@ -77,6 +81,12 @@ export function encodeBinary(value: $.youtube.GetCommentsSectionParams.Params.Op
[15, tsValueToWireValueFns.int32(tsValue)],
);
}
if (value.commentId !== undefined) {
const tsValue = value.commentId;
result.push(
[16, tsValueToWireValueFns.string(tsValue)],
);
}
return serialize(result);
}

Expand Down Expand Up @@ -105,5 +115,12 @@ export function decodeBinary(binary: Uint8Array): $.youtube.GetCommentsSectionPa
if (value === undefined) break field;
result.type = value;
}
field: {
const wireValue = wireFields.get(16);
if (wireValue === undefined) break field;
const value = wireValueToTsValueFns.string(wireValue);
if (value === undefined) break field;
result.commentId = value;
}
return result;
}
6 changes: 4 additions & 2 deletions src/proto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export function encodeMessageParams(channel_id: string, video_id: string): strin

export function encodeCommentsSectionParams(video_id: string, options: {
type?: number,
sort_by?: 'TOP_COMMENTS' | 'NEWEST_FIRST'
sort_by?: 'TOP_COMMENTS' | 'NEWEST_FIRST',
comment_id?: string
} = {}): string {
const sort_options = {
TOP_COMMENTS: 0,
Expand All @@ -171,7 +172,8 @@ export function encodeCommentsSectionParams(video_id: string, options: {
opts: {
videoId: video_id,
sortBy: sort_options[options.sort_by || 'TOP_COMMENTS'],
type: options.type || 2
type: options.type || 2,
commentId: options.comment_id || ''
},
target: 'comments-section'
}
Expand Down
1 change: 1 addition & 0 deletions src/proto/youtube.proto
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ message GetCommentsSectionParams {
required string video_id = 4;
required int32 sort_by = 6;
required int32 type = 15;
optional string comment_id = 16;
}

message RepliesOptions {
Expand Down

0 comments on commit a5f6209

Please sign in to comment.