Fix MessageContext exhaustive-deps for CI builds
Stabilize schedulePostStreamRefetch with useCallback so CI=true ESLint no longer fails beta deploy.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { createContext, ReactNode, useContext, useEffect, useRef, useState } from "react";
|
import { createContext, ReactNode, useCallback, useContext, useEffect, useRef, useState } from "react";
|
||||||
import { WebSocketContext } from "./WebSocketContext";
|
import { WebSocketContext } from "./WebSocketContext";
|
||||||
import { AccountContext } from "./AccountContext";
|
import { AccountContext } from "./AccountContext";
|
||||||
import { ConversationContext } from "./ConversationContext";
|
import { ConversationContext } from "./ConversationContext";
|
||||||
@@ -128,7 +128,7 @@ const MessageProvider = ( {children}: MessageProviderProps) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const schedulePostStreamRefetch = () => {
|
const schedulePostStreamRefetch = useCallback(() => {
|
||||||
if (refetchTimerRef.current) clearTimeout(refetchTimerRef.current)
|
if (refetchTimerRef.current) clearTimeout(refetchTimerRef.current)
|
||||||
const conversationId = selectedConversationRef.current
|
const conversationId = selectedConversationRef.current
|
||||||
if (!conversationId) return
|
if (!conversationId) return
|
||||||
@@ -137,7 +137,7 @@ const MessageProvider = ( {children}: MessageProviderProps) => {
|
|||||||
refetchTimerRef.current = setTimeout(() => {
|
refetchTimerRef.current = setTimeout(() => {
|
||||||
void GetConversationDetails(conversationId)
|
void GetConversationDetails(conversationId)
|
||||||
}, 800)
|
}, 800)
|
||||||
}
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
GetConversationDetails(selectedConversation)
|
GetConversationDetails(selectedConversation)
|
||||||
@@ -316,7 +316,7 @@ const MessageProvider = ( {children}: MessageProviderProps) => {
|
|||||||
/* unsubscribe from channel during cleanup */
|
/* unsubscribe from channel during cleanup */
|
||||||
unsubscribe(channelName)
|
unsubscribe(channelName)
|
||||||
}
|
}
|
||||||
}, [account, subscribe, unsubscribe, conversationDetails, selectedConversation, setSelectedConversation])
|
}, [account, subscribe, unsubscribe, conversationDetails, selectedConversation, setSelectedConversation, schedulePostStreamRefetch])
|
||||||
|
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
|||||||
Reference in New Issue
Block a user