@@ -97,7 +97,9 @@ export class AppComponent implements OnInit {
97
97
}
98
98
} ) ;
99
99
this . preventOldSettings ( ) ;
100
+
100
101
this . setSettings ( ) ;
102
+
101
103
this . getFeedVideos ( ) ;
102
104
}
103
105
@@ -122,13 +124,17 @@ export class AppComponent implements OnInit {
122
124
return playerVars ;
123
125
}
124
126
125
- getFeedVideos ( ) {
126
- this . _shared . getFeed ( ) . subscribe ( data => {
127
- this . feedVideos = data ;
128
- if ( ! this . currentVideo . id ) {
129
- this . setDefaultPlayer ( ) ;
130
- }
131
- } ) ;
127
+ async getFeedVideos ( ) {
128
+ await this . _shared . initFeed ( ) ;
129
+ await this . _shared . initChannel ( ) ;
130
+ this . feedVideos = this . _shared . feedVideos ;
131
+ if ( ! this . currentVideo . id ) {
132
+ this . setDefaultPlayer ( ) ;
133
+ }
134
+ }
135
+
136
+ async getChannel ( ) {
137
+ await this . _shared . initChannel ( ) ;
132
138
}
133
139
134
140
setCurrentVideoObject ( data : any ) {
@@ -186,7 +192,6 @@ export class AppComponent implements OnInit {
186
192
this . stopRange ( ) ;
187
193
if ( this . currentState ) {
188
194
this . videoRangeTimer = setInterval ( ( ) => {
189
- console . log ( 'Rangeu merge de nebun...' ) ;
190
195
this . videoCurRange = this . player . getCurrentTime ( ) ;
191
196
this . videoCurFull = this . timeFormat ( this . videoCurRange ) ;
192
197
this . videoRangePercent = ( this . videoCurRange / this . videoMaxRange ) * 100 ;
@@ -347,7 +352,7 @@ export class AppComponent implements OnInit {
347
352
// ---------------- Init settings ----------------
348
353
349
354
preventOldSettings ( ) {
350
- if ( localStorage . length === 1 || localStorage . getItem ( 'version' ) === null ) {
355
+ if ( localStorage . length === 1 || ! localStorage . getItem ( 'version' ) ) {
351
356
console . log ( 'Updating localstorage...' ) ;
352
357
localStorage . removeItem ( 'version' ) ;
353
358
localStorage . removeItem ( 'playlist' ) ;
@@ -359,14 +364,13 @@ export class AppComponent implements OnInit {
359
364
}
360
365
}
361
366
362
- setSettings ( ) {
363
- this . _shared . getSettings ( ) . subscribe ( data => {
364
- this . regionCode = data . api_settings [ 1 ] . value ;
365
- this . thumbnails = data . form_settings [ 0 ] . value ;
366
- this . displayVideoPlayer = data . form_settings [ 2 ] . value ;
367
- this . repeatMode = data . form_settings [ 3 ] . value ;
368
- this . darkMode = data . form_settings [ 4 ] . value ;
369
- } ) ;
367
+ async setSettings ( ) {
368
+ await this . _shared . getSettings ( ) ;
369
+ this . regionCode = this . _shared . settings . api_settings [ 1 ] . value ;
370
+ this . thumbnails = this . _shared . settings . form_settings [ 0 ] . value ;
371
+ this . displayVideoPlayer = this . _shared . settings . form_settings [ 2 ] . value ;
372
+ this . repeatMode = this . _shared . settings . form_settings [ 3 ] . value ;
373
+ this . darkMode = this . _shared . settings . form_settings [ 4 ] . value ;
370
374
}
371
375
372
376
toggleHeadSettings ( int : number ) {
@@ -421,36 +425,24 @@ export class AppComponent implements OnInit {
421
425
}
422
426
}
423
427
424
- getStatsVideos ( query : string ) {
425
- this . youtube . statsVideos ( query ) . subscribe (
426
- result => {
427
- this . currentVideo . id = result [ 'items' ] [ 0 ] . id ;
428
- this . currentVideo . title = result [ 'items' ] [ 0 ] . snippet . title ;
429
- this . currentVideo . channelTitle = result [ 'items' ] [ 0 ] . snippet . channelTitle ;
430
- this . currentVideo . stats . likes = result [ 'items' ] [ 0 ] . statistics . likeCount ;
431
- this . currentVideo . stats . dislikes = result [ 'items' ] [ 0 ] . statistics . dislikeCount ;
432
- this . currentVideo . stats . views = result [ 'items' ] [ 0 ] . statistics . viewCount ;
433
- this . shareLink = 'https://youtu.be/' + this . currentVideo . id ;
434
- } ,
435
- error => {
436
- console . log ( 'error on related videos' ) ;
437
- }
438
- ) ;
428
+ async getStatsVideos ( query : string ) {
429
+ const res = await this . youtube . statsVideos ( query ) ;
430
+ this . currentVideo . id = res [ 'items' ] [ 0 ] . id ;
431
+ this . currentVideo . title = res [ 'items' ] [ 0 ] . snippet . title ;
432
+ this . currentVideo . channelTitle = res [ 'items' ] [ 0 ] . snippet . channelTitle ;
433
+ this . currentVideo . stats . likes = res [ 'items' ] [ 0 ] . statistics . likeCount ;
434
+ this . currentVideo . stats . dislikes = res [ 'items' ] [ 0 ] . statistics . dislikeCount ;
435
+ this . currentVideo . stats . views = res [ 'items' ] [ 0 ] . statistics . viewCount ;
436
+ this . shareLink = 'https://youtu.be/' + this . currentVideo . id ;
439
437
}
440
438
441
- getRelatedVideos ( ) {
442
- this . youtube . relatedVideos ( this . currentVideo . id ) . subscribe (
443
- result => {
444
- this . relatedVideos = result [ 'items' ] ;
445
- if ( this . playlistPrefill ) {
446
- this . playlistInit ( ) ;
447
- this . playlistPrefill = false ;
448
- }
449
- } ,
450
- error => {
451
- console . log ( 'error on related videos' ) ;
452
- }
453
- ) ;
439
+ async getRelatedVideos ( ) {
440
+ const res = await this . youtube . relatedVideos ( this . currentVideo . id ) ;
441
+ this . relatedVideos = res [ 'items' ] ;
442
+ if ( this . playlistPrefill ) {
443
+ this . playlistInit ( ) ;
444
+ this . playlistPrefill = false ;
445
+ }
454
446
}
455
447
456
448
// ---------------- Player controls ----------------
@@ -636,7 +628,7 @@ export class AppComponent implements OnInit {
636
628
let listType ;
637
629
const youtubeLink = 'https://youtu.be/' ;
638
630
if ( list === 0 ) {
639
- listType = this . feedVideos [ i ] ;
631
+ listType = this . _shared . feedVideos [ i ] ;
640
632
}
641
633
if ( list === 1 ) {
642
634
listType = this . _shared . lastSearchedVideos [ i ] ;
@@ -677,7 +669,6 @@ export class AppComponent implements OnInit {
677
669
678
670
copyShareLink ( ) {
679
671
if ( ! this . notify . enabled ) {
680
- console . log ( 'test' ) ;
681
672
document . execCommand ( 'Copy' ) ;
682
673
this . _shared . triggerNotify ( 'Copied' ) ;
683
674
this . updateNotify ( ) ;
0 commit comments