diff --git a/package.json b/package.json index 625522b..99d0b3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "TraewellingWidget", - "version": "1.1.0", + "version": "1.1.1", "description": "An iOS widget for Scriptable, which shows your stats about your latest train rides checked in via Traewelling.", "main": "TraewellingWidget.js", "scripts": { diff --git a/src/TraewellingWidget.js b/src/TraewellingWidget.js index c534ffb..97f3777 100644 --- a/src/TraewellingWidget.js +++ b/src/TraewellingWidget.js @@ -115,11 +115,22 @@ async function main() { // Update script - if (areRepoUpdatesAvailable) { - try { - await updater.updateScript(scriptName); - } catch (error) { - console.log(`${error.line}: ${error.message}`); + if (areRepoUpdatesAvailable && config.runsInApp) { + let inputAlert = new Alert(); + inputAlert.title = "Traewelling Widget Update"; + inputAlert.message = "There is an update for Traewelling Widget.\n\nDo you want to install it?"; + + inputAlert.addAction("No"); + inputAlert.addAction("Yes"); + + let buttonIndex = await inputAlert.present(); + + if (buttonIndex === 1) { + try { + await updater.updateScript(scriptName); + } catch (error) { + console.log(`${error.line}: ${error.message}`); + } } } @@ -307,9 +318,7 @@ async function main() { async function createWidget(traewelling, widgetParams) { let widget = generateBaseWidget(); - if (widgetParams.areRepoUpdatesAvailable) { - widget.url = sourceRepoUrl; - } else { + if (!widgetParams.areRepoUpdatesAvailable) { let userinfo = await traewelling.getUserInfo(); widget.url = `https://traewelling.de/@${userinfo.data.username}`; } @@ -340,7 +349,7 @@ async function createWidget(traewelling, widgetParams) { } if (widgetParams.areRepoUpdatesAvailable) - subtitle = "update available"; + subtitle = "click to update"; let widgetFamily = config.widgetFamily; if (widgetFamily === undefined) {