File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 6262 } ) ;
6363 } ;
6464
65+ var checkForNewDataFromYouTube = function ( cache ) {
66+ var compareDataFromCacheAndYouTube = function ( result ) {
67+ var isUnchanged = false ;
68+ if ( cache . items && result . items && result . items . length ) {
69+ if ( cache . items . length == result . items . length ) {
70+ var flag = false ;
71+ for ( let i = 0 ; i < cache . items . length ; i ++ ) {
72+ if ( cache . items [ i ] . id != result . items [ i ] . id ) {
73+ flag = true ;
74+ }
75+ }
76+ if ( ! flag ) {
77+ isUnchanged = true ;
78+ }
79+ }
80+ }
81+ if ( ! isUnchanged ) {
82+ WidgetFeed . videos = [ ] ;
83+ WidgetFeed . busy = false ;
84+ WidgetFeed . nextPageToken = null ;
85+ setTimeout ( ( ) => {
86+ if ( ! $scope . loading ) {
87+ getFeedVideosSuccess ( result ) ;
88+ }
89+ } , 0 ) ;
90+ if ( ! $scope . $$phase ) $scope . $digest ( ) ;
91+ }
92+ } ;
93+ var errorWithComperation = function ( err ) {
94+ console . error ( "Error while getting data" , err ) ;
95+ } ;
96+
97+ if ( currentPlayListId && currentPlayListId !== "1" ) {
98+ YoutubeApi . getFeedVideos (
99+ currentPlayListId ,
100+ VIDEO_COUNT . LIMIT ,
101+ null
102+ ) . then ( compareDataFromCacheAndYouTube , errorWithComperation ) ;
103+ }
104+ } ;
65105 /*
66106 * Fetch user's data from datastore
67107 */
72112 if ( err || ! data || data . rssUrl != result . data . content . rssUrl || ! data . forcedCleanupv2 )
73113 return ;
74114 getFeedVideosSuccess ( data ) ;
115+ checkForNewDataFromYouTube ( data ) ;
75116 } ) ;
76117
77118 WidgetFeed . data = result . data ;
You can’t perform that action at this time.
0 commit comments