@jetthai/cuora 1.0.156 → 1.0.158

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.158](https://github.com/jetthai/cuora-module/compare/v1.0.157...v1.0.158) (2022-08-11)
6
+
7
+ ### [1.0.157](https://github.com/jetthai/cuora-module/compare/v1.0.156...v1.0.157) (2022-08-11)
8
+
5
9
  ### [1.0.156](https://github.com/jetthai/cuora-module/compare/v1.0.152-2...v1.0.156) (2022-08-02)
6
10
 
7
11
  ### [1.0.155](https://github.com/jetthai/cuora-module/compare/v1.0.152-1...v1.0.155) (2022-08-02)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jetthai/cuora",
3
- "version": "1.0.156",
3
+ "version": "1.0.158",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -25,7 +25,6 @@ export default function (request) {
25
25
  },
26
26
  },
27
27
  room: {
28
- entry: 'resetRoomHistory',
29
28
  initial: 'home',
30
29
  states: {
31
30
  home: {
@@ -35,22 +34,46 @@ export default function (request) {
35
34
  entry: assign({ room: (context, event) => context.menu['favorite'] }),
36
35
  },
37
36
  hot: {
38
- entry: assign({ room: (context, event) => context.menu['hot'] }),
37
+ entry: assign((context, event) => {
38
+ if (!context.roomHistory.some((item) => item.id === context.menu.hot.id)) {
39
+ return { room: context.menu['hot'] }
40
+ }
41
+ }),
39
42
  },
40
43
  new: {
41
- entry: assign({ room: (context, event) => context.menu['new'] }),
44
+ entry: assign((context, event) => {
45
+ if (!context.roomHistory.some((item) => item.id === context.menu.new.id)) {
46
+ return { room: context.menu['new'] }
47
+ }
48
+ }),
42
49
  },
43
50
  slot: {
44
- entry: assign({ room: (context, event) => context.menu['slot'] }),
51
+ entry: assign((context, event) => {
52
+ if (!context.roomHistory.some((item) => item.id === context.menu.slot.id)) {
53
+ return { room: context.menu['slot'] }
54
+ }
55
+ }),
45
56
  },
46
57
  fish: {
47
- entry: assign({ room: (context, event) => context.menu['fish'] }),
58
+ entry: assign((context, event) => {
59
+ if (!context.roomHistory.some((item) => item.id === context.menu.fish.id)) {
60
+ return { room: context.menu['fish'] }
61
+ }
62
+ }),
48
63
  },
49
64
  arcade: {
50
- entry: assign({ room: (context, event) => context.menu['arcade'] }),
65
+ entry: assign((context, event) => {
66
+ if (!context.roomHistory.some((item) => item.id === context.menu.arcade.id)) {
67
+ return { room: context.menu['arcade'] }
68
+ }
69
+ }),
51
70
  },
52
71
  table: {
53
- entry: assign({ room: (context, event) => context.menu['table'] }),
72
+ entry: assign((context, event) => {
73
+ if (!context.roomHistory.some((item) => item.id === context.menu.table.id)) {
74
+ return { room: context.menu['table'] }
75
+ }
76
+ }),
54
77
  },
55
78
  search: {},
56
79
  history: {
@@ -61,23 +84,23 @@ export default function (request) {
61
84
  feature: {
62
85
  on: {
63
86
  RETURN: { target: 'room.history' },
64
- CLICK_HOT: { target: 'room.hot' },
65
- CLICK_NEW: { target: 'room.new' },
87
+ CLICK_HOT: { target: 'room.hot', actions: 'resetRoomHistory' },
88
+ CLICK_NEW: { target: 'room.new', actions: 'resetRoomHistory' },
66
89
  },
67
90
  },
68
91
  category: {
69
92
  on: {
70
93
  RETURN: { target: 'room.history' },
71
- CLICK_SLOT: { target: 'room.slot' },
72
- CLICK_FISH: { target: 'room.fish' },
73
- CLICK_ARCADE: { target: 'room.arcade' },
74
- CLICK_TABLE: { target: 'room.table' },
94
+ CLICK_SLOT: { target: 'room.slot', actions: 'resetRoomHistory' },
95
+ CLICK_FISH: { target: 'room.fish', actions: 'resetRoomHistory' },
96
+ CLICK_ARCADE: { target: 'room.arcade', actions: 'resetRoomHistory' },
97
+ CLICK_TABLE: { target: 'room.table', actions: 'resetRoomHistory' },
75
98
  },
76
99
  },
77
100
  },
78
101
  on: {
79
- CLICK_HOME: { target: 'room.home' },
80
- CLICK_FAVORITE: { target: 'room.favorite' },
102
+ CLICK_HOME: { target: 'room.home', actions: 'resetRoomHistory' },
103
+ CLICK_FAVORITE: { target: 'room.favorite', actions: 'resetRoomHistory' },
81
104
  CLICK_FEATURE: { target: 'feature' },
82
105
  CLICK_CATEGORY: { target: 'category' },
83
106
  CLICK_SEARCH: { target: 'room.search' },
@@ -122,7 +122,7 @@ export default function (request) {
122
122
  const currentRoom = event.data
123
123
  return {
124
124
  room: currentRoom,
125
- roomHistory: [...context.roomHistory, currentRoom],
125
+ roomHistory: [...context.roomHistory, context.room],
126
126
  }
127
127
  }),
128
128
  backwardRoom: assign((context, event) => {
@@ -151,7 +151,7 @@ function createSideAction(name) {
151
151
  return assign((context, event) => {
152
152
  const { roomHistory } = context
153
153
  if (roomHistory.some((history) => history.id === context.menu[name].id)) {
154
- return { room: roomHistory.slice(-1)[0] }
154
+ return { room: roomHistory.slice(-1)[0], roomHistory: roomHistory.slice(0, -1) }
155
155
  } else {
156
156
  return { room: context.menu[name], roomHistory: [context.menu[name]] }
157
157
  }