Skip to content

Commit

Permalink
Fixed info updates
Browse files Browse the repository at this point in the history
  • Loading branch information
smirko-dev committed Dec 6, 2021
1 parent 65c89da commit 151062c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 12 additions & 5 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ else {
}

// Register for the unload event
me.onunload = saveSettings;
appbit.onunload = saveSettings;

// Load settings at startup
let settings = loadSettings();
applySettings(settings.info, settings.color);

// Apply and store settings
function applySettings(info, color) {
//DEBUG console.log(`[applySettings] info=${info}, color=${color}`);
if (typeof info !== 'undefined') {
if (info !== 'weather') {
infoIcon.image = `${info}.png`;
Expand Down Expand Up @@ -108,6 +109,9 @@ if (appbit.permissions.granted('access_calendar')) {
renderAppointment();
});
}
else {
console.warn('Missing permission: access_calendar');
}

if (appbit.permissions.granted('access_location')) {
weather.initialize(data => {
Expand All @@ -117,6 +121,9 @@ if (appbit.permissions.granted('access_location')) {
WeatherIcon = `${data.icon}`;
});
}
else {
console.warn('Missing permission: access_location');
}

display.addEventListener("change", () => {
if (display.on) {
Expand Down Expand Up @@ -144,12 +151,11 @@ function renderAppointment() {
const date = fromEpochSec(event.startDate);
appointmentsLabel.text = timeString(date) + " " + event.title;
hideInfo();
}
else {
showInfo();
updateInfo();
return;
}
}
showInfo();
updateInfo();
}

function hideInfo() {
Expand All @@ -165,6 +171,7 @@ function showInfo() {
}

function updateInfo() {
//DEBUG console.log(`[updateInfo] info=${settings.info}`);
if (settings.info === 'weather') {
infoLabel.text = WeatherValue;
infoIcon.image = WeatherIcon;
Expand Down
2 changes: 0 additions & 2 deletions settings/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ function settingsFunc(props) {
{ name: `${gettext("cal")}`, value: 'calories' },
{ name: `${gettext("weather")}`, value: 'weather' }
]}
onSelection={(value) => console.log(`Selected info = ${value}`)}
/>
<ColorSelect
settingsKey="color"
Expand All @@ -27,7 +26,6 @@ function settingsFunc(props) {
{color: '#ed1abc'},
{color: 'silver'}
]}
onSelection={(color) => console.log(`Selected color = ${color}`)}
/>
</Section>
</Page>
Expand Down

0 comments on commit 151062c

Please sign in to comment.