fix chat fetcher stops, change fetcher code
This commit is contained in:
parent
3fb35e8123
commit
c89ac79140
2 changed files with 3 additions and 4 deletions
|
@ -112,14 +112,14 @@ const chats = {
|
||||||
setChatListFetcher (state, { commit, fetcher }) {
|
setChatListFetcher (state, { commit, fetcher }) {
|
||||||
const prevFetcher = state.chatListFetcher
|
const prevFetcher = state.chatListFetcher
|
||||||
if (prevFetcher) {
|
if (prevFetcher) {
|
||||||
prevFetcher()
|
prevFetcher.stop()
|
||||||
}
|
}
|
||||||
state.chatListFetcher = fetcher && fetcher()
|
state.chatListFetcher = fetcher && fetcher()
|
||||||
},
|
},
|
||||||
setCurrentChatFetcher (state, { fetcher }) {
|
setCurrentChatFetcher (state, { fetcher }) {
|
||||||
const prevFetcher = state.fetcher
|
const prevFetcher = state.fetcher
|
||||||
if (prevFetcher) {
|
if (prevFetcher) {
|
||||||
prevFetcher()
|
prevFetcher.stop()
|
||||||
}
|
}
|
||||||
state.fetcher = fetcher && fetcher()
|
state.fetcher = fetcher && fetcher()
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,9 +8,8 @@
|
||||||
export const promiseInterval = (promiseCall, interval) => {
|
export const promiseInterval = (promiseCall, interval) => {
|
||||||
let stopped = false
|
let stopped = false
|
||||||
let timeout = null
|
let timeout = null
|
||||||
let func = () => {}
|
|
||||||
|
|
||||||
func = () => {
|
const func = () => {
|
||||||
promiseCall().finally(() => {
|
promiseCall().finally(() => {
|
||||||
if (stopped) return
|
if (stopped) return
|
||||||
timeout = window.setTimeout(func, interval)
|
timeout = window.setTimeout(func, interval)
|
||||||
|
|
Loading…
Reference in a new issue