fix(api): groupNotify.refresh() adapt delay-debounce

This commit is contained in:
Il Harper 2024-09-10 14:38:36 +08:00
parent 1edea8a220
commit 1228b3f17d
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC

View File

@ -1,13 +1,7 @@
import { debounce } from 'lodash-es'
import { getSingleScreenNotifies } from '../definitions/groupService'
let t = new Date().getTime()
const refresh = async () => {
const nt = new Date().getTime()
if (nt - t < 10000) return
t = nt
const refreshIntl2 = async () => {
void getSingleScreenNotifies({
doubt: false,
startSeq: '',
@ -20,6 +14,12 @@ const refresh = async () => {
})
}
const refreshIntl1 = debounce(refreshIntl2, 2000, {
maxWait: 2000,
})
const refresh = () => setTimeout(refreshIntl1, 2000)
export const groupNotify = {
refresh,
}