Skip to content

Commit

Permalink
use fullHtmlEventsUrl
Browse files Browse the repository at this point in the history
Get SSE for the specific page instance.
  • Loading branch information
jonathansick committed Apr 3, 2024
1 parent 731af8b commit 089a274
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import React from 'react';
import { fetchEventSource } from '@microsoft/fetch-event-source';

import useTimesSquarePage from '../../hooks/useTimesSquarePage';
import { TimesSquareUrlParametersContext } from '../TimesSquareUrlParametersProvider';

export const TimesSquareHtmlEventsContext = React.createContext();

Expand All @@ -13,11 +15,14 @@ export default function TimesSquareHtmlEventsProvider({ children }) {
const [abortController, setAbortController] = React.useState(
new AbortController()
);

const { urlQueryString } = React.useContext(TimesSquareUrlParametersContext);
const { htmlEventsUrl } = useTimesSquarePage();
const fullHtmlEventsUrl = `${htmlEventsUrl}?${urlQueryString}`;

React.useEffect(async () => {
async function runEffect() {
await fetchEventSource(htmlEventsUrl, {
await fetchEventSource(fullHtmlEventsUrl, {
method: 'GET',
signal: abortController.signal,
onopen(res) {
Expand Down Expand Up @@ -51,7 +56,7 @@ export default function TimesSquareHtmlEventsProvider({ children }) {
abortController.abort();
setAbortController(new AbortController());
};
}, [htmlEventsUrl]);
}, [fullHtmlEventsUrl]);

const contextValue = {
dateSubmitted: htmlEvent ? htmlEvent.date_submitted : null,
Expand Down

0 comments on commit 089a274

Please sign in to comment.