diff --git a/lib/tunnelbroker/peer-to-peer-context.js b/lib/tunnelbroker/peer-to-peer-context.js --- a/lib/tunnelbroker/peer-to-peer-context.js +++ b/lib/tunnelbroker/peer-to-peer-context.js @@ -53,7 +53,8 @@ if (messageIDs) { messages = await sqliteAPI.getOutboundP2PMessagesByID(messageIDs); } else { - messages = await sqliteAPI.getAllOutboundP2PMessage(); + const allMessages = await sqliteAPI.getAllOutboundP2PMessage(); + messages = allMessages.filter(message => message.supportsAutoRetry); } const devicesMap: { [deviceID: string]: OutboundP2PMessage[] } = {}; @@ -139,6 +140,8 @@ } } +const AUTOMATIC_RETRY_FREQUENCY = 30 * 1000; + function PeerToPeerProvider(props: Props): React.Node { const { children } = props; @@ -178,6 +181,14 @@ [identityContext, sendMessage], ); + React.useEffect(() => { + const intervalID = setInterval( + () => processOutboundMessages(), + AUTOMATIC_RETRY_FREQUENCY, + ); + return () => clearInterval(intervalID); + }, [processOutboundMessages]); + const value: PeerToPeerContextType = React.useMemo( () => ({ processOutboundMessages,