import { defineStore } from "pinia"; import { v4 as uuid } from "uuid"; export const useScannerStore = defineStore("scanner", { state: () => { return { inUse: false as boolean, roomId: undefined as undefined | string, results: [] as Array, connectedDevices: 0 as number, }; }, actions: { startSession() { if (this.inUse) return; this.roomId = uuid(); this.inUse = true; }, endSession() { this.inUse = false; this.roomId = undefined; this.results = []; }, removeElementFromResults(el: string) { this.results = this.results.filter((result) => result !== el); }, }, });