feat(CommentsView): parse voice_reply_transcript (#981)

* Parse the VoiceReplyContainer instead of just parsing the text
This commit is contained in:
ChunkyProgrammer
2025-06-17 16:26:50 +00:00
committed by GitHub
parent 1705470558
commit d6f13e20ac
4 changed files with 35 additions and 2 deletions

View File

@@ -1,8 +1,10 @@
import { Parser } from '../../index.js';
import { YTNode } from '../../helpers.js';
import NavigationEndpoint from '../NavigationEndpoint.js';
import Author from '../misc/Author.js';
import Text from '../misc/Text.js';
import CommentReplyDialog from './CommentReplyDialog.js';
import VoiceReplyContainerView from './VoiceReplyContainerView.js';
import { InnertubeError } from '../../../utils/Utils.js';
import * as ProtoUtils from '../../../utils/ProtoUtils.js';
@@ -63,6 +65,8 @@ export default class CommentView extends YTNode {
public is_disliked?: boolean;
public is_hearted?: boolean;
public voice_reply_container?: VoiceReplyContainerView | null;
constructor(data: RawNode) {
super();
@@ -78,7 +82,7 @@ export default class CommentView extends YTNode {
};
}
applyMutations(comment?: RawNode, toolbar_state?: RawNode, toolbar_surface?: RawNode) {
applyMutations(comment?: RawNode, toolbar_state?: RawNode, toolbar_surface?: RawNode, comment_surface?: RawNode) {
if (comment) {
this.content = Text.fromAttributed(comment.properties.content);
this.published_time = comment.properties.publishedTime;
@@ -129,6 +133,12 @@ export default class CommentView extends YTNode {
this.reply_command = new NavigationEndpoint(toolbar_surface.replyCommand);
}
}
if (comment_surface) {
if ('voiceReplyContainerViewModel' in comment_surface) {
this.voice_reply_container = Parser.parseItem(comment_surface.voiceReplyContainerViewModel, VoiceReplyContainerView);
}
}
}
/**