added debug code to display how often mithril redraws

This commit is contained in:
Youen Toupin 2022-04-09 20:05:22 +02:00
parent 3f03e8f8ba
commit 184f1cee33
2 changed files with 9 additions and 1 deletions

View File

@ -4,8 +4,11 @@ require("./layout.css");
export default class Layout {
private menuActive = false;
private drawCount = 0;
view(vnode: m.Vnode) {
this.drawCount = this.drawCount + 1;
return [
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
@ -16,6 +19,8 @@ export default class Layout {
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
<span>{this.drawCount}</span>
</div>
<div id="mainMenu" class={'navbar-menu ' + (this.menuActive ? 'is-active' : '')}>

View File

@ -17,7 +17,10 @@ export class DashboardPage extends Page {
}
async refresh() {
this.status = await MonitorApi.get().fetchStatus();
let newStatus = await MonitorApi.get().fetchStatus();
if(this.status == null)
m.redraw();
this.status = newStatus;
// todo: update widgets (avoiding to use m.redraw which is a bit costly on CPU)
if(this.autoRefresh)
setTimeout(() => { if(this.autoRefresh) this.refresh(); }, 500);