@jetthai/cuora 1.1.366-dev-12 → 1.1.366

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,6 @@
1
1
  export default {
2
2
  get(name, options) {
3
- let itemStr = null
4
- try {
5
- itemStr = localStorage.getItem(name)
6
- } catch (error) {
7
- console.error(`Error getting item from localStorage: ${error}`)
8
- return null
9
- }
3
+ const itemStr = localStorage.getItem(name)
10
4
 
11
5
  if (!itemStr) {
12
6
  return null
@@ -18,7 +12,7 @@ export default {
18
12
  return null
19
13
  }
20
14
 
21
- return 'value' in item ? item.value : item
15
+ return item.value
22
16
  },
23
17
  set(name, value, options) {
24
18
  const item = { value }
@@ -26,17 +20,9 @@ export default {
26
20
  if (options?.maxAge) {
27
21
  item.expiry = new Date().getTime() + options.maxAge * 1000
28
22
  }
29
- try {
30
- localStorage.setItem(name, JSON.stringify(item))
31
- } catch (error) {
32
- console.error(`Error setting item in localStorage: ${error}`)
33
- }
23
+ localStorage.setItem(name, JSON.stringify(item))
34
24
  },
35
25
  remove(name, options) {
36
- try {
37
- localStorage.removeItem(name)
38
- } catch (error) {
39
- console.error(`Error removing item from localStorage: ${error}`)
40
- }
26
+ localStorage.removeItem(name)
41
27
  },
42
28
  }
@@ -1,46 +0,0 @@
1
- import { assign, createMachine } from 'xstate'
2
- import game from '../api/game.js'
3
-
4
- export default function (request, context) {
5
- const { appSecret } = request.config
6
- const { providerId, seqNo, lang } = context
7
- return createMachine(
8
- {
9
- id: 'game_betslip',
10
- initial: 'fetching',
11
- context: {
12
- gameBetSlip: {},
13
- },
14
- states: {
15
- fetching: {
16
- invoke: {
17
- src: 'fetchBetslip',
18
- onDone: {
19
- target: 'idle',
20
- actions: 'setBetslip',
21
- },
22
- onError: {
23
- target: 'idle',
24
- },
25
- },
26
- },
27
- idle: {},
28
- },
29
- },
30
- {
31
- actions: {
32
- setBetslip: assign((context, event) => {
33
- return {
34
- gameBetSlip: event.data,
35
- }
36
- }),
37
- },
38
- services: {
39
- // 取得遊戲注單
40
- fetchBetslip: async (context, event) => {
41
- return await request.send(game.getBetslip({ providerId, seqNo, lang, appSecret }))
42
- },
43
- },
44
- }
45
- )
46
- }
@@ -1,28 +0,0 @@
1
- export default {
2
- get(name, options) {
3
- const itemStr = sessionStorage.getItem(name)
4
-
5
- if (!itemStr) {
6
- return null
7
- }
8
-
9
- const item = JSON.parse(itemStr)
10
- if (item.expiry && new Date().getTime() > item.expiry) {
11
- sessionStorage.removeItem(name)
12
- return null
13
- }
14
-
15
- return item.value
16
- },
17
- set(name, value, options) {
18
- const item = { value }
19
-
20
- if (options?.maxAge) {
21
- item.expiry = new Date().getTime() + options.maxAge * 1000
22
- }
23
- sessionStorage.setItem(name, JSON.stringify(item))
24
- },
25
- remove(name, options) {
26
- sessionStorage.removeItem(name)
27
- },
28
- }