@@ -14,7 +14,7 @@ const DEFAULTSETTINGS = {
14
14
autoReload : false , // Automatically reload watch after app App Loader actions (removes "Hold button" prompt)
15
15
noPackets : false , // Enable File Upload Compatibility mode (disables binary packet upload)
16
16
} ;
17
- var SETTINGS = JSON . parse ( JSON . stringify ( DEFAULTSETTINGS ) ) ; // clone
17
+ let SETTINGS = JSON . parse ( JSON . stringify ( DEFAULTSETTINGS ) ) ; // clone
18
18
19
19
let device = {
20
20
id : undefined , // The Espruino device ID of this device, eg. BANGLEJS
@@ -39,7 +39,7 @@ let device = {
39
39
"Alarm" : "Alarm"
40
40
}
41
41
};*/
42
- var LANGUAGE = undefined ;
42
+ let LANGUAGE = undefined ;
43
43
44
44
function appJSONLoadedHandler ( ) {
45
45
appJSON . forEach ( app => {
@@ -782,6 +782,7 @@ function showScreenshots(appId) {
782
782
783
783
// =========================================== My Apps
784
784
785
+ /** Upload the given app to the device - may prompt user for dependencies */
785
786
function uploadApp ( app , options ) {
786
787
options = options || { } ;
787
788
if ( app . type == "defaultconfig" && ! options . force ) {
@@ -823,22 +824,22 @@ function uploadApp(app, options) {
823
824
} ) ;
824
825
}
825
826
827
+ /** Prompt user and then remove app from the device */
826
828
function removeApp ( app ) {
827
- return showPrompt ( "Delete" , "Really remove '" + app . name + "'?" ) . then ( ( ) => {
828
- return getInstalledApps ( ) . then ( ( ) => {
829
- // a = from appid.info, app = from apps.json
830
- return Comms . removeApp ( device . appsInstalled . find ( a => a . id === app . id ) ) ;
829
+ return showPrompt ( "Delete" , "Really remove '" + app . name + "'?" )
830
+ . then ( ( ) => getInstalledApps ( ) )
831
+ . then ( ( ) => Comms . removeApp ( device . appsInstalled . find ( a => a . id === app . id ) ) ) // a = from appid.info, app = from apps.json
832
+ . then ( ( ) => {
833
+ device . appsInstalled = device . appsInstalled . filter ( a => a . id != app . id ) ;
834
+ showToast ( app . name + " removed successfully" , "success" ) ;
835
+ refreshMyApps ( ) ;
836
+ refreshLibrary ( ) ;
837
+ } , err => {
838
+ showToast ( app . name + " removal failed, " + err , "error" ) ;
831
839
} ) ;
832
- } ) . then ( ( ) => {
833
- device . appsInstalled = device . appsInstalled . filter ( a => a . id != app . id ) ;
834
- showToast ( app . name + " removed successfully" , "success" ) ;
835
- refreshMyApps ( ) ;
836
- refreshLibrary ( ) ;
837
- } , err => {
838
- showToast ( app . name + " removal failed, " + err , "error" ) ;
839
- } ) ;
840
840
}
841
841
842
+ /** Show window for a new app and finally upload it */
842
843
function customApp ( app ) {
843
844
return handleCustomApp ( app ) . then ( ( appJSON ) => {
844
845
if ( appJSON ) device . appsInstalled . push ( appJSON ) ;
@@ -852,7 +853,7 @@ function customApp(app) {
852
853
} ) ;
853
854
}
854
855
855
- /* check for dependencies the app needs and install them if required
856
+ /** check for dependencies the app needs and install them if required
856
857
uploadOptions is an object, see AppInfo.checkDependencies for what can be in it
857
858
*/
858
859
function checkDependencies ( app , uploadOptions ) {
@@ -1405,4 +1406,4 @@ if (btn) btn.addEventListener("click",event=>{
1405
1406
document . querySelector ( ".editor__canvas" ) . style . display = "inherit" ;
1406
1407
Comms . on ( "data" , x => Espruino . Core . Terminal . outputDataHandler ( x ) )
1407
1408
Espruino . Core . Terminal . setInputDataHandler ( function ( d ) { Comms . write ( d ) ; } )
1408
- } ) ;
1409
+ } ) ;
0 commit comments