1+ import type { RawNode } from '../types/RawResponse.js' ;
2+ import { YTNode } from '../helpers.js' ;
3+ import NavigationEndpoint from './NavigationEndpoint.js' ;
4+
5+ interface ButtonContent {
6+ button_text : string ;
7+ accessibility_text : string ;
8+ image_name : string ;
9+ subscribe_state_subscribed : boolean ;
10+ endpoint : NavigationEndpoint ;
11+ }
12+
13+ export default class SubscribeButtonView extends YTNode {
14+ static type = 'SubscribeButtonView' ;
15+
16+ public subscribe_button_content : ButtonContent ;
17+ public unsubscribe_button_content : ButtonContent ;
18+ public disable_notification_bell : boolean ;
19+ public button_style : {
20+ unsubscribed_state_style : string ;
21+ subscribed_state_style : string ;
22+ } ;
23+ public is_signed_out : boolean ;
24+ public background_style : string ;
25+ public disable_subscribe_button : boolean ;
26+ public on_show_subscription_options : NavigationEndpoint ;
27+ public channel_id : string ;
28+ public enable_subscribe_button_post_click_animation : boolean ;
29+ public bell_accessiblity_data : {
30+ off_label : string ;
31+ all_label : string ;
32+ occasional_label : string ;
33+ disabled_label : string ;
34+ } ;
35+
36+ constructor ( data : RawNode ) {
37+ super ( ) ;
38+
39+ this . subscribe_button_content = this . #parseButtonContent( data . subscribeButtonContent ) ;
40+ this . unsubscribe_button_content = this . #parseButtonContent( data . unsubscribeButtonContent ) ;
41+
42+ this . disable_notification_bell = data . disableNotificationBell ;
43+ this . button_style = {
44+ unsubscribed_state_style : data . buttonStyle . unsubscribedStateStyle ,
45+ subscribed_state_style : data . buttonStyle . subscribedStateStyle
46+ } ;
47+ this . is_signed_out = data . isSignedOut ;
48+ this . background_style = data . backgroundStyle ;
49+ this . disable_subscribe_button = data . disableSubscribeButton ;
50+ this . on_show_subscription_options = new NavigationEndpoint ( data . onShowSubscriptionOptions ) ;
51+ this . channel_id = data . channelId ;
52+ this . enable_subscribe_button_post_click_animation = data . enableSubscribeButtonPostClickAnimation ;
53+ this . bell_accessiblity_data = {
54+ off_label : data . bellAccessibilityData . offLabel ,
55+ all_label : data . bellAccessibilityData . allLabel ,
56+ occasional_label : data . bellAccessibilityData . occasionalLabel ,
57+ disabled_label : data . bellAccessibilityData . disabledLabel
58+ } ;
59+ }
60+
61+ #parseButtonContent( data : RawNode ) : ButtonContent {
62+ return {
63+ button_text : data . buttonText ,
64+ accessibility_text : data . accessibilityText ,
65+ image_name : data . imageName ,
66+ subscribe_state_subscribed : data . subscribeState . subscribed ,
67+ endpoint : new NavigationEndpoint ( data . onTapCommand )
68+ } ;
69+ }
70+ }
0 commit comments