diff --git a/package-lock.json b/package-lock.json index 0dc21ffa..8dfe96df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12538,9 +12538,9 @@ } }, "node_modules/source-map-js": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz", - "integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", "engines": { "node": ">=0.10.0" } diff --git a/src/components/atoms/WorkoutBluetooth/WorkoutBluetooth.vue b/src/components/atoms/WorkoutBluetooth/WorkoutBluetooth.vue index 74d3e12e..b1fee9d4 100644 --- a/src/components/atoms/WorkoutBluetooth/WorkoutBluetooth.vue +++ b/src/components/atoms/WorkoutBluetooth/WorkoutBluetooth.vue @@ -12,26 +12,25 @@ import { mySmartBoard, Progressor, active, - battery, connect, disconnect, - info, notify } from '@hangtime/grip-connect' import type { massObject } from '@hangtime/grip-connect/src/types/notify' import { useBluetoothStore } from '@/stores/bluetooth' +const { device } = storeToRefs(useBluetoothStore()) + const workout = defineModel() -const { showDialog = false, size = 'default' } = defineProps<{ - showDialog?: boolean +const { size = 'default' } = defineProps<{ size?: string }>() -const emit = defineEmits(['notify', 'active', 'start', 'show-dialog']) +const emit = defineEmits(['notify', 'active', 'start']) -const { device } = storeToRefs(useBluetoothStore()) +const dialog = ref(false) const devices = [ { @@ -84,121 +83,127 @@ const reset = () => { device.value = null } -const onSuccess = async () => { - try { - // set the device - device.value = dropdown.value - - // Listen for notifications - notify((data: massObject) => { - emit('notify', data) - output.value = JSON.stringify(data) - }) - - active((value: boolean) => { - emit('active', value) - }) - - if (device.value?.name === Motherboard.filters.some((filter) => filter.name)) { - await battery(device.value) - await info(device.value) +const setup = () => { + connect( + dropdown.value, + async () => { + device.value = dropdown.value + + // Listen for notifications + notify((data: massObject) => { + emit('notify', data) + // output.value = JSON.stringify(data) + }) + + active((value: boolean) => { + emit('active', value) + }) + + // Close Dialog + dialog.value = false + // Start workout + emit('start') + }, + (error: Error) => { + errorElm.value = error } - } catch (error) { - console.error(error) - } finally { - emit('show-dialog', false) - emit('start') - } -} - -const onError = (error: Error) => { - errorElm.value = error + ) }