Skip to content

Commit

Permalink
Correct update time interval
Browse files Browse the repository at this point in the history
  • Loading branch information
greatbalin committed Sep 5, 2019
1 parent e1a38e1 commit 1099e16
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions plasmoid/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Item {
id: execute_ds
engine: "executable"

property var tick
property var tick: 0

// what data is requested from the systemmonitor data source
connectedSources: {
Expand Down Expand Up @@ -78,11 +78,12 @@ Item {
values[i] = normalize(orig_values, data.stdout, i)
}
}
var current_tick = Math.floor(Date.now() / 1000)
if (tick != current_tick) {
var current_tick = Date.now()
var time_spent = current_tick - tick
if (time_spent > interval ) {
valuesChanged()
orig_valuesChanged()
tick = current_tick
tick = tick + (Math.floor(time_spent / interval) * interval)
}
}

Expand All @@ -95,7 +96,7 @@ Item {
id: systemmonitor
engine: "systemmonitor"

property var tick
property var tick: 0

// what data is requested from the systemmonitor data source
connectedSources: {
Expand Down Expand Up @@ -126,11 +127,12 @@ Item {
values[i] = normalize(orig_values, data.value, i)
}
}
var current_tick = Math.floor(Date.now() / 1000)
if (tick != current_tick) {
var current_tick = Date.now()
var time_spent = current_tick - tick
if (time_spent > interval ) {
valuesChanged()
orig_valuesChanged()
tick = current_tick
tick = tick + (Math.floor(time_spent / interval) * interval)
}
}

Expand Down

0 comments on commit 1099e16

Please sign in to comment.