Apply suggestions from code review of branch refactor/migrate_vuex_to_pinia

Co-authored-by: Julian Stirling <julian@julianstirling.co.uk>
This commit is contained in:
Antonio Anaya 2026-04-30 21:24:29 +00:00
parent ebd67cd410
commit 67f253eecd
6 changed files with 24 additions and 7 deletions

View file

@ -249,6 +249,9 @@ export default {
handleExit() {}, handleExit() {},
/**
* Handle global mouse wheel events to be associated with navigation
*/
wheelMonitor(event) { wheelMonitor(event) {
if ( if (
event.target.parentNode.classList.contains("scrollTarget") || event.target.parentNode.classList.contains("scrollTarget") ||
@ -261,6 +264,13 @@ export default {
} }
}, },
/**
* Jog for key-presses.
*
* This is a similar to the function in stageControlButtons.vue however it uses
* uses the key repeat to fire in case a key up is missed. It debounces any
* request to jog that is too recent after the last jog.
*/
jog(x, y, z) { jog(x, y, z) {
const now = Date.now(); const now = Date.now();
if (now - this.lastJogTime < this.jogTime) { if (now - this.lastJogTime < this.jogTime) {
@ -275,6 +285,13 @@ export default {
eventBus.emit("globalUpdatePositionEvent"); eventBus.emit("globalUpdatePositionEvent");
}, },
/**
* Stop jogging on key-up
*
* This is also similar to the function in stageControlButtons.vue. It handles
* stopping jogging and resetting the `lastJogTime` so there is no delay when
* starting a new jog after an old jog finished.
*/
jogStop() { jogStop() {
this.invokeAction("stage", "jog", { stop: true }); this.invokeAction("stage", "jog", { stop: true });
this.lastJogTime = 0; this.lastJogTime = 0;
@ -283,6 +300,9 @@ export default {
}, 100); }, 100);
}, },
/**
* Track which keys are still down on keypress (or key repeat).
*/
updateJogFromKeys() { updateJogFromKeys() {
let x = 0, let x = 0,
y = 0, y = 0,

View file

@ -68,7 +68,9 @@ export default {
computed: { computed: {
propertyDescription: function () { propertyDescription: function () {
const td = this.wotStore.thingDescriptions[this.thingName]; const td = this.wotStore.thingDescriptions[this.thingName];
// Return `undefined` if the thing doesn't exist or has no properties
if (!td || !td.properties) return undefined; if (!td || !td.properties) return undefined;
// JS returns `undefined` if this property name doesn't exist
return td.properties[this.propertyName]; return td.properties[this.propertyName];
}, },
}, },

View file

@ -104,8 +104,6 @@ export default {
...mapWritableState(useSettingsStore, ["navigationInvert"]), ...mapWritableState(useSettingsStore, ["navigationInvert"]),
}, },
// TODO: jogInterval may need to be cleared on "beforeUnmount()"
methods: { methods: {
/** /**
* Jog d-pad and focus buttons. * Jog d-pad and focus buttons.

View file

@ -66,10 +66,10 @@ export default {
} }
this.modalConfirm(message).then( this.modalConfirm(message).then(
() => { () => {
this.resetState();
this.deleteAllThingDescriptions();
// Post and silence errors // Post and silence errors
axios.post(this.thingActionUrl("system", action)).catch(() => {}); axios.post(this.thingActionUrl("system", action)).catch(() => {});
this.resetState();
this.deleteAllThingDescriptions();
}, },
() => {}, () => {},
); );

View file

@ -42,8 +42,6 @@
import propertyControl from "@/components/labThingsComponents/propertyControl.vue"; import propertyControl from "@/components/labThingsComponents/propertyControl.vue";
import ServerSpecifiedInterface from "@/components/labThingsComponents/serverSpecifiedInterface.vue"; import ServerSpecifiedInterface from "@/components/labThingsComponents/serverSpecifiedInterface.vue";
import { useIntersectionObserver } from "@vueuse/core"; import { useIntersectionObserver } from "@vueuse/core";
//import { mapWritableState } from "pinia";
//import { useSettingsStore } from "@/stores/settings.js";
export default { export default {
name: "SlideScanControls", name: "SlideScanControls",

View file

@ -64,7 +64,6 @@ export const useSettingsStore = defineStore(
function removeStream(id) { function removeStream(id) {
activeStreams.value[id] = false; activeStreams.value[id] = false;
} }
// TODO: Replace for direct access to state.
// Getters // Getters
const baseUri = computed(() => origin.value); const baseUri = computed(() => origin.value);
const ready = computed(() => available.value); const ready = computed(() => available.value);