🔧 Tooling for resumable socket.io sessions

This commit is contained in:
2023-07-27 11:08:51 -07:00
parent 26fdb6d3a4
commit 11ef9e6e2a
7 changed files with 36 additions and 24 deletions

View File

@@ -19,7 +19,7 @@ import {
} from "../context/AirDCPPSocket";
import { SocketIOProvider } from "../context/SocketIOContext";
import socketIOConnectionInstance from "../shared/socket.io/instance";
import { isEmpty, isUndefined } from "lodash";
import { isEmpty, isNil, isUndefined } from "lodash";
import {
AIRDCPP_DOWNLOAD_PROGRESS_TICK,
LS_SINGLE_IMPORT,
@@ -97,13 +97,23 @@ const AirDCPPSocketComponent = (): ReactElement => {
return <></>;
};
export const App = (): ReactElement => {
const dispatch = useDispatch();
useEffect(() => {
// Listen for the sessionInitialized event
socketIOConnectionInstance.on("sessionInitialized", (sessionId) => {
console.log(sessionId);
// Store the session ID in Redux state
// initSession(sessionId);
});
// Check if there is a sessionId in localStorage
const sessionId = localStorage.getItem("sessionId");
if (!isNil(sessionId)) {
// Resume the session
dispatch({
type: "RESUME_SESSION",
meta: { remote: true },
data: { sessionId },
});
} else {
// Inititalize the session and persist the sessionId to localStorage
socketIOConnectionInstance.on("sessionInitialized", (sessionId) => {
localStorage.setItem("sessionId", sessionId);
});
}
}, []);
return (
<SocketIOProvider socket={socketIOConnectionInstance}>

View File

@@ -48,7 +48,9 @@ export const ComicInfoXML = (data): ReactElement => {
<dd>
<span className="is-size-7">{json.notes[0]}</span>
</dd>
<dd className="mt-1 mb-1">{json.summary[0]}</dd>
<dd className="mt-1 mb-1">
{!isUndefined(json.summary) && json.summary[0]}
</dd>
</dl>
</div>
);

View File

@@ -21,7 +21,7 @@ export const PullList = ({ issues }: PullListProps): ReactElement => {
useEffect(() => {
dispatch(
getWeeklyPullList({
startDate: "2023-5-25",
startDate: "2023-7-25",
pageSize: "15",
currentPage: "1",
}),

View File

@@ -15,7 +15,7 @@ export const PullList = (): ReactElement => {
useEffect(() => {
dispatch(
getWeeklyPullList({
startDate: "2022-11-15",
startDate: "2023-7-28",
pageSize: "15",
currentPage: "1",
}),
@@ -109,15 +109,15 @@ export const PullList = (): ReactElement => {
{!isNil(pullListComics) && (
<div>
<div className="library">
<T2Table
sourceData={pullListComics}
columns={columnData}
totalPages={pullListComics.length}
paginationHandlers={{
nextPage: nextPageHandler,
previousPage: previousPageHandler,
}}
/>
<T2Table
sourceData={pullListComics}
columns={columnData}
totalPages={pullListComics.length}
paginationHandlers={{
nextPage: nextPageHandler,
previousPage: previousPageHandler,
}}
/>
</div>
</div>
)}