From a7e2e0cd1efb42bcf8f6fbd46efde2961be7687d Mon Sep 17 00:00:00 2001 From: Dave Alden Date: Thu, 7 Sep 2017 09:04:49 +0100 Subject: [PATCH] Handle edge case where preferred app is no longer avaiable on device --- www/common.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/www/common.js b/www/common.js index ff8168d..b6e057b 100644 --- a/www/common.js +++ b/www/common.js @@ -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(); } @@ -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); };