Add Vuex position and timestamp getters for real-time event

This commit is contained in:
D. Berge
2022-02-27 18:42:06 +01:00
parent febf109cce
commit 606f18c016

View File

@@ -32,4 +32,19 @@ function point (state) {
return Number(v) || v;
}
export default { serverEvent, online, lineName, sequence, line, point };
function position (state) {
const λ = Number(_(state, "serverEvent.payload.new.meta.longitude"));
const φ = Number(_(state, "serverEvent.payload.new.meta.latitude"));
if (!isNaN(λ) && !isNaN(φ)) {
return [ λ, φ ];
}
return null;
}
function timestamp (state) {
const v = _(state, "serverEvent.payload.new.meta.time");
return v;
}
export default { serverEvent, online, lineName, sequence, line, point, position, timestamp };