ui_migration refactor(store) Remove lingering getters at wot.js pinia store

This commit is contained in:
Antonio Anaya 2026-05-24 18:16:01 -06:00
parent ace7ae9855
commit f8c4ffe62b

View file

@ -9,6 +9,10 @@ export const useWotStore = defineStore(
const thingDescriptions = ref({}); const thingDescriptions = ref({});
const servient = ref(null); const servient = ref(null);
const helpers = ref(null); const helpers = ref(null);
// Getters
const thingList = computed(() => Object.keys(thingDescriptions.value));
// Actions // Actions
function addThingDescription(thingName, thingDescription) { function addThingDescription(thingName, thingDescription) {
thingDescriptions.value[thingName] = thingDescription; thingDescriptions.value[thingName] = thingDescription;
@ -42,21 +46,17 @@ export const useWotStore = defineStore(
} }
} }
const thingList = computed(() => Object.keys(thingDescriptions.value)); function thingAvailable(thingName) {
const thingAvailable = computed(() => (thingName) => {
return thingName in thingDescriptions.value; return thingName in thingDescriptions.value;
}); }
const thingAffordanceAvailable = computed(() => (thing, affordanceType, affordance) => { function thingAffordanceAvailable(thing, affordanceType, affordance) {
const td = thingDescriptions.value[thing]; const td = thingDescriptions.value[thing];
if (!td || !td[affordanceType]) return false; if (!td || !td[affordanceType]) return false;
return affordance in td[affordanceType]; return affordance in td[affordanceType];
}); }
const thingFormUrl = computed( function thingFormUrl(thing, affordanceType, affordance, op, allowUndefined = true) {
() =>
(thing, affordanceType, affordance, op, allowUndefined = true) => {
// Find the URL for a particular operation // Find the URL for a particular operation
const td = thingDescriptions.value[thing]; const td = thingDescriptions.value[thing];
if (!td) { if (!td) {
@ -82,18 +82,17 @@ export const useWotStore = defineStore(
return base + href; return base + href;
} }
return href; return href;
}, }
);
const thingPropertyUrl = computed(() => (thing, property, op, allowUndefined) => { function thingPropertyUrl(thing, property, op, allowUndefined) {
// Find the URL for a particular property // Find the URL for a particular property
return thingFormUrl.value(thing, "properties", property, op, allowUndefined); return thingFormUrl(thing, "properties", property, op, allowUndefined);
}); }
const thingActionUrl = computed(() => (thing, action, op, allowUndefined) => { function thingActionUrl(thing, action, op, allowUndefined) {
// Find the URL for a particular action // Find the URL for a particular action
return thingFormUrl.value(thing, "actions", action, op, allowUndefined); return thingFormUrl(thing, "actions", action, op, allowUndefined);
}); }
return { return {
thingDescriptions, thingDescriptions,