Skip to content

Commit

Permalink
dirty as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
xnuk committed May 21, 2022
1 parent 3bd936d commit df153d7
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ export const List = () => {
}
},
)
const [lastLogUpdate, setLastLogUpdate] = useState(0)

useEffect(() => {
setLastLogUpdate(Date.now())
}, [itemName, exists?.place, exists?.count, exists?.tab])

useEffect(() => {
if (itemName == null) return
Expand All @@ -34,14 +39,22 @@ export const List = () => {
useEffect(() => {
if (itemName != null) {
setLastItemName(itemName)
setExistsCache(prev => ({
...prev,
[itemName]: {},
}))

if (Date.now() - lastLogUpdate > 700) {
setExistsCache(prev => ({
...prev,
[itemName]: {},
}))
}
return
}

if (lastItemName == null || exists == null) return
if (
lastItemName == null ||
exists == null ||
Date.now() - lastLogUpdate > 700
)
return

setExistsCache(prev => {
const orig: readonly string[] =
Expand Down

0 comments on commit df153d7

Please sign in to comment.