Skip to content

Commit

Permalink
Synchronize list of active web clips with available web clips
Browse files Browse the repository at this point in the history
[Issue] #1372
[Problem] When webclip removed from server it is still available to user
[Solution] Update active web clips list according to the available webclips.

Signed-off-by: Lukasz Slachciak <l.slachciak@samsung.com>
  • Loading branch information
lmslachciak committed Aug 28, 2020
1 parent ecfed62 commit b76528d
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions examples/mobile/HomeApp/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,11 @@
"use strict";
var tau = window.tau,

webClipList = [
"webclip/tv-remote-control/",
"webclip/restaurant/",
"webclip/weather/",
"webclip/apps-on-tv/",
"webclip/latest-news/",
"webclip/now-on-tv"
],
webClipList = [],
activeWebClipList = [
"webclip/tv-remote-control/",
"webclip/restaurant/",
"webclip/weather/"
"webclip/tv-remote-control",
"webclip/restaurant",
"webclip/weather"
];

function loadWeatherJS() {
Expand Down Expand Up @@ -48,6 +41,28 @@
.then((response) => response.json())
.then((data) => {
webClipList = data;
// make sure that default active webclip list contains only available elements
activeWebClipList.forEach(function (webclip) {
if (!webClipList.includes(webclip)) {
activeWebClipList.splice(activeWebClipList.indexOf(webclip), 1);
}
})
})
.catch(() => {
// use default webclip list is sth wrong
webClipList =
[
"webclip/tv-remote-control",
"webclip/restaurant",
"webclip/weather",
"webclip/apps-on-tv",
"webclip/latest-news",
"webclip/now-on-tv"
]
})
.finally(() => {
updateWebClipsUI();
updateWebClipListPopup();
});
}

Expand Down Expand Up @@ -169,8 +184,6 @@

loadWeatherJS();
loadWebClipList();
updateWebClipsUI();
updateWebClipListPopup();
}

function onPageBeforeShow(event) {
Expand Down

0 comments on commit b76528d

Please sign in to comment.