From 97947882df35421356ca2e05d3b7902ba879420c Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 12 Sep 2024 09:42:08 +0300 Subject: [PATCH] Subrise/Sunset widget: check location permission --- main/sunrise-sunset-widget.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main/sunrise-sunset-widget.lua b/main/sunrise-sunset-widget.lua index b7a3fa9..4cf97e8 100644 --- a/main/sunrise-sunset-widget.lua +++ b/main/sunrise-sunset-widget.lua @@ -10,8 +10,16 @@ local json = require "json" local fmt = require "fmt" function on_alarm() - local location=system:location() - local url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&formatted=0" + local location = system:location() + + if location == nil then + return + elseif location == "permission_error" then + ui:show_text("No location permission") + return + end + + local url = "https://api.sunrise-sunset.org/json?lat=" .. location[1] .. "&lng=" .. location[2] .. "&formatted=0" http:get(url) end