@ozdao/prometheus-framework 0.2.239 → 0.2.241

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/prometheus-framework",
3
- "version": "0.2.239",
3
+ "version": "0.2.241",
4
4
  "description": "Web3 Framework focused on user experience and ease of development.",
5
5
  "author": "OZ DAO <hello@ozdao.dev>",
6
6
  "license": "GPL-3.0-or-later",
@@ -28,6 +28,7 @@ const isScanning = ref(false)
28
28
  const isTorchAvailable = ref(false)
29
29
  const minZoomRatio = ref(undefined)
30
30
  const maxZoomRatio = ref(undefined)
31
+ const isProcessing = ref(false)
31
32
 
32
33
  onMounted(async () => {
33
34
  const { supported } = await BarcodeScanner.isSupported()
@@ -45,26 +46,22 @@ onUnmounted(async () => {
45
46
  async function startScan() {
46
47
  try {
47
48
  const { camera } = await BarcodeScanner.checkPermissions()
48
-
49
49
  if (camera !== 'granted') {
50
50
  const { camera: newStatus } = await BarcodeScanner.requestPermissions()
51
51
  if (newStatus !== 'granted') {
52
52
  throw new Error('Camera permission is required to scan barcodes')
53
53
  }
54
54
  }
55
-
56
55
  document.querySelector('body')?.classList.add('barcode-scanner-active')
57
56
  document.querySelector('html')?.classList.add('barcode-scanner-active-html')
58
57
  BarcodeScanner.hideBackground();
59
-
60
58
  isScanning.value = true
61
-
62
59
  await BarcodeScanner.addListener('barcodeScanned', async (result) => {
63
- await processBarcode(result.barcode)
60
+ if (!isProcessing.value) {
61
+ await processBarcode(result.barcode)
62
+ }
64
63
  })
65
-
66
64
  await BarcodeScanner.startScan()
67
-
68
65
  const { zoomRatio: min } = await BarcodeScanner.getMinZoomRatio()
69
66
  const { zoomRatio: max } = await BarcodeScanner.getMaxZoomRatio()
70
67
  minZoomRatio.value = min
@@ -89,17 +86,21 @@ async function stopScan() {
89
86
  }
90
87
 
91
88
  async function processBarcode(barcode) {
89
+ if (isProcessing.value) return
90
+ isProcessing.value = true
92
91
  try {
93
- if (!barcode) {
94
- throw new Error('Troubles with barcode reading')
92
+ if (!barcode || !barcode.rawValue) {
93
+ throw new Error('Invalid barcode data')
95
94
  }
96
- const response = await tickets.actions.update({ _id: barcode, status: 'used', check: true })
95
+ console.log('barcode is', barcode)
96
+ const response = await tickets.actions.update({ _id: barcode.rawValue, status: 'used', check: true })
97
97
  alert("Ticket checked. And it's all right!")
98
+ emits('qrcodecheck')
98
99
  } catch (e) {
100
+ console.error(e)
99
101
  alert(`Ticket is not found, already used or deactivated!`)
100
102
  } finally {
101
- emits('qrcodecheck')
102
- await stopScan()
103
+ isProcessing.value = false
103
104
  }
104
105
  }
105
106
 
@@ -146,15 +147,15 @@ async function toggleTorch() {
146
147
  }
147
148
 
148
149
  /* Existing styles */
149
- body.barcode-scanner-active {
150
+ /*body.barcode-scanner-active {
150
151
  visibility: hidden !important;
151
152
  background: transparent !important;
152
153
  --background: transparent;
153
154
  --ion-background-color: transparent;
154
155
  opacity: 0;
155
- }
156
+ }*/
156
157
 
157
- html.barcode-scanner-active-html {
158
+ /*html.barcode-scanner-active-html {
158
159
  background: transparent !important;
159
- }
160
+ }*/
160
161
  </style>