Skip to content

Commit

Permalink
Handle edge case where preferred app is no longer avaiable on device
Browse files Browse the repository at this point in the history
  • Loading branch information
dpa99c committed Sep 7, 2017
1 parent 71791ba commit a7e2e0c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions www/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,11 +528,20 @@ ln.userSelect = function(destination, options, successCallback, errorCallback){
});
};

var checkForChoice = function(){
var checkForChoice = function(availableApps){
getItem("choice", function(choice){
if(choice){
app = choice;
launchApp();
if(availableApps[choice]){
app = choice;
launchApp();
}else{
// Chosen app is no longer available on device
ln.appSelection.userChoice.clear(function(){
ln.appSelection.userPrompted.clear(function(){
displayChooser();
});
})
}
}else{
displayChooser();
}
Expand Down Expand Up @@ -604,7 +613,7 @@ ln.userSelect = function(destination, options, successCallback, errorCallback){
buttonMap[buttonList.length] = "cancel"; // Add an entry for cancel button

// Check if a user choice exists
checkForChoice();
checkForChoice(apps);

}, options.errorCallback);
};
Expand Down

0 comments on commit a7e2e0c

Please sign in to comment.