Display the changelog, but only on the 1st time after an update

This commit is contained in:
Starbeamrainbowlabs 2019-05-09 13:38:51 +01:00
parent 721c813599
commit 6413171e6d
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
2 changed files with 20 additions and 5 deletions

View File

@ -72,8 +72,7 @@ class Guage {
let draw_x = guage_size.x + guage_size.width + 3;
let draw_y = guage_size.y + (value * guage_size.height);
// this.context.fillStyle = "black";
console.log(`Writing '${point}' to (${draw_x}, ${draw_y})`);
// console.log(`Writing '${point}' to (${draw_x}, ${draw_y})`);
this.context.fillText(point, draw_x, draw_y);
this.context.beginPath();

View File

@ -6,6 +6,22 @@ import NanoModal from 'nanomodal';
import Config from './Config.mjs';
import GetFromUrl from './Helpers/GetFromUrl.mjs';
async function show_changelog(only_if_changed) {
let current_version = `${Config.version}, built ${Config.build_date.toDateString()}`;
console.log(`[UI] Comparing current '${current_version}' to '${localStorage.getItem("last_seen_version")}'`);
if(only_if_changed && localStorage.getItem("last_seen_version") == current_version) {
console.log("[UI] Not showing changelog.");
return false;
}
console.log("[UI] Showing changelog");
NanoModal(
await GetFromUrl(`${Config.api_root}?action=changelog`)
).show();
localStorage.setItem("last_seen_version", current_version);
return true;
}
class UI {
constructor(in_config, in_map_manager) {
this.config = in_config;
@ -56,13 +72,13 @@ class UI {
type: "button",
name: `${Config.version}, built ${Config.build_date.toDateString()}`,
callback: (async (_event) => {
NanoModal(
await GetFromUrl(`${Config.api_root}?action=changelog`)
).show();
show_changelog(false);
})
}
]);
this.ui_panel.setIndex("Reading Type", this.reading_types.findIndex((type) => type.short_descr == "PM25"));
await show_changelog(true);
}
}