|
55 | 55 | var compareDataFromCacheAndYouTube = function(result){ |
56 | 56 | var isUnchanged=false; |
57 | 57 | if(cache.items && result.items && result.items.length){ |
| 58 | + result.items = result.items.filter(item => ( |
| 59 | + item.snippet && |
| 60 | + item.snippet.thumbnails && |
| 61 | + Object.keys(item.snippet.thumbnails).length)); |
| 62 | + |
58 | 63 | if(cache.items.length == result.items.length){ |
59 | 64 | var flag=false; |
60 | 65 | for (let i = 0; i < cache.items.length; i++) { |
|
96 | 101 | */ |
97 | 102 | var initData = function(isRefresh) { |
98 | 103 | var success = function(result) { |
| 104 | + if ($scope.deeplinkData && !$scope.isDeeplinkItemOpened) { |
| 105 | + processDeeplink($scope.deeplinkData, false); |
| 106 | + } |
99 | 107 | cache.getCache(function(err, data) { |
100 | 108 | // if the rss feed url has changed, ignore the cache and update when fetched. Also, if forcedCleanupv2 is false, it will skip cache and proceed with fetching. |
101 | 109 | if (err || !data || data.rssUrl != result.data.content.rssUrl || !data.forcedCleanupv2) { |
|
104 | 112 | getFeedVideosSuccess(data); |
105 | 113 | checkForNewDataFromYouTube(data); |
106 | 114 | } |
107 | | - if ($scope.deeplinkData) { |
| 115 | + if ($scope.deeplinkData && !$scope.isDeeplinkItemOpened) { |
108 | 116 | processDeeplink($scope.deeplinkData, false); |
109 | 117 | } |
110 | 118 | if (!$rootScope.$$phase) $rootScope.$digest(); |
|
190 | 198 | $scope.isDeeplinkItemOpened = false; |
191 | 199 | // show the deeplink skeleton if the deeplink is present |
192 | 200 | buildfire.deeplink.getData(function (data) { |
193 | | - if (data && data.link) { |
| 201 | + if (data && (data.link || data.feed)) { |
194 | 202 | $rootScope.showFeed = false; |
195 | 203 | toggleDeeplinkSkeleton(true); |
196 | 204 | $scope.deeplinkData = data; |
197 | 205 | } |
198 | 206 | }); |
199 | 207 | buildfire.deeplink.onUpdate(function (data) { |
200 | | - if (data && data.link) { |
| 208 | + if (data && (data.link || data.feed)) { |
201 | 209 | $scope.deeplinkData = data; |
202 | 210 | toggleDeeplinkSkeleton(true); |
203 | 211 | processDeeplink(data, true); |
204 | 212 | } |
205 | 213 | }); |
206 | 214 |
|
207 | 215 | function processDeeplink (data, pushToHistory=true) { |
208 | | - if (data && data.link) { |
| 216 | + if (data && data.feed) { |
| 217 | + let id = data.feed.id; |
| 218 | + if (id.indexOf("yt:video") > -1) { |
| 219 | + id = id.slice(id.lastIndexOf(":") + 1, id.length); |
| 220 | + } |
| 221 | + if (data.timeIndex) video.seekTo = data.timeIndex; |
| 222 | + $scope.isDeeplinkItemOpened = true; |
| 223 | + WidgetFeed.openDetailsPage({ |
| 224 | + ...data.feed, id, |
| 225 | + snippet: { |
| 226 | + title: data.feed.title, |
| 227 | + description:data.feed.description, |
| 228 | + thumbnails: { |
| 229 | + default: { |
| 230 | + url: data.feed.image_url |
| 231 | + } |
| 232 | + } |
| 233 | + }, |
| 234 | + }, pushToHistory); |
| 235 | + } else if (data && data.link) { |
209 | 236 | let linkD = data.link; |
210 | 237 | if (linkD.indexOf("yt:video") > -1) { |
211 | 238 | linkD = linkD.slice(linkD.lastIndexOf(":") + 1, linkD.length); |
|
255 | 282 | var getFeedVideosSuccess = function(result) { |
256 | 283 | // double check that result is not null |
257 | 284 | if (result && result.items && result.items.length) { |
| 285 | + result.items = result.items.filter(item => ( |
| 286 | + item.snippet && |
| 287 | + item.snippet.thumbnails && |
| 288 | + Object.keys(item.snippet.thumbnails).length)); |
| 289 | + |
258 | 290 | $rootScope.showEmptyState = false; |
259 | 291 | } else { |
260 | 292 | $rootScope.showEmptyState = true; |
|
457 | 489 | if (WidgetFeed.screenAnimationInProgress) return; |
458 | 490 | WidgetFeed.screenAnimationInProgress = true; |
459 | 491 |
|
460 | | - if (video.snippet.resourceId && video.snippet.resourceId.videoId) { |
| 492 | + if (video.snippet && video.snippet.resourceId && video.snippet.resourceId.videoId) { |
461 | 493 | video.id = video.snippet.resourceId.videoId; |
462 | 494 | } |
463 | 495 | VideoCache.setCache({...video, pushToHistory}); |
|
473 | 505 | $rootScope.loading = false; |
474 | 506 | WidgetFeed.screenAnimationInProgress = false; |
475 | 507 | viewedVideos.markViewed($scope, video); |
476 | | - const videoId = (video.snippet.resourceId && video.snippet.resourceId.videoId) ? video.snippet.resourceId.videoId : video.id; |
| 508 | + const videoId = (video.snippet && video.snippet.resourceId && video.snippet.resourceId.videoId) ? video.snippet.resourceId.videoId : video.id; |
477 | 509 | Location.goTo("#/video/" + videoId); |
478 | 510 |
|
479 | 511 | setTimeout(() => { |
|
0 commit comments