@@ -43,7 +43,6 @@ export default function App() {
43
43
useEffect ( ( ) => {
44
44
let selfId : number | undefined
45
45
let lastTimestamp = ""
46
- let lastAction = - 1
47
46
let currentZone = "Unknown"
48
47
49
48
let timeoutId : number | undefined = undefined
@@ -134,8 +133,7 @@ export default function App() {
134
133
( actionId >= 9 && actionId <= 30000 ) ||
135
134
actionId === SPRINT_ACTION_ID
136
135
const isCraftingAction = actionId >= 100001 && actionId <= 100300
137
- const isBugOrDuplicate =
138
- logTimestamp === lastTimestamp && actionId === lastAction
136
+ const isBugOrDuplicate = logTimestamp === lastTimestamp
139
137
const isItem = ability . startsWith ( "item_" )
140
138
141
139
if (
@@ -146,36 +144,27 @@ export default function App() {
146
144
}
147
145
148
146
if ( Date . now ( ) - Date . parse ( lastTimestamp ) > 120000 ) {
149
- openNewEncounter ( ) //last action > 120s ago
147
+ openNewEncounter ( ) // last action > 120s ago
150
148
}
151
149
152
150
lastTimestamp = logTimestamp
153
- lastAction = actionId
154
151
155
- let keyToRemove : string | null = null
152
+ const key = logTimestamp
156
153
157
- // This is pretty silly but it's the neatest way to handle the updates going
158
- // out at the same time, without finding some way to merge the action lists....
159
- ReactDOM . unstable_batchedUpdates ( ( ) => {
154
+ ReactDOM . flushSync ( ( ) => {
160
155
setActionList ( ( actionList ) => {
161
156
const lastAction = actionList . at ( - 1 )
162
157
163
- keyToRemove = lastAction ?. key ?? null
164
-
165
158
if ( logCode === LINE_ID . NetworkCancelAbility ) {
166
159
return actionList . slice ( 0 , - 1 )
167
160
} else if (
168
161
lastAction ?. actionId === actionId &&
169
162
lastAction ?. casting
170
163
) {
171
164
const nextActionList = actionList . slice ( )
172
- nextActionList [ nextActionList . length - 1 ] = {
173
- ...lastAction ,
174
- casting : false ,
175
- }
165
+ nextActionList [ nextActionList . length - 1 ] . casting = false
176
166
return nextActionList
177
167
} else {
178
- const key = logTimestamp
179
168
return actionList . concat ( {
180
169
actionId,
181
170
ability,
@@ -184,6 +173,7 @@ export default function App() {
184
173
} )
185
174
}
186
175
} )
176
+
187
177
setEncounterList ( ( encounterList ) => {
188
178
if ( logCode !== LINE_ID . NetworkAbility ) return encounterList
189
179
@@ -200,13 +190,11 @@ export default function App() {
200
190
} )
201
191
} )
202
192
203
- if ( keyToRemove != null ) {
204
- timeoutId = window . setTimeout ( ( ) => {
205
- setActionList ( ( actionList ) =>
206
- actionList . filter ( ( action ) => action . key !== keyToRemove ) ,
207
- )
208
- } , 10000 )
209
- }
193
+ timeoutId = window . setTimeout ( ( ) => {
194
+ setActionList ( ( actionList ) =>
195
+ actionList . filter ( ( action ) => action . key !== key ) ,
196
+ )
197
+ } , 10000 )
210
198
}
211
199
} ,
212
200
} )
0 commit comments