From 041332edfa31bca798480104f8eca197aac84fc0 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 9 Sep 2024 03:17:28 +0530 Subject: [PATCH] feat: emit getList socket events from context --- src/context/browserActions.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/context/browserActions.tsx b/src/context/browserActions.tsx index 6590913a..2ab82553 100644 --- a/src/context/browserActions.tsx +++ b/src/context/browserActions.tsx @@ -1,4 +1,5 @@ import React, { createContext, useContext, useState, ReactNode } from 'react'; +import { useSocketStore } from './socket'; export type PaginationType = 'scrollDown' | 'scrollUp' | 'clickNext' | 'clickLoadMore' | 'none' | ''; export type LimitType = '10' | '100' | 'custom' | ''; @@ -39,6 +40,8 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => { const [limitType, setLimitType] = useState(''); const [customLimit, setCustomLimit] = useState(''); + const {socket} = useSocketStore(); + const updatePaginationType = (type: PaginationType) => setPaginationType(type); const updateLimitType = (type: LimitType) => setLimitType(type); const updateCustomLimit = (limit: string) => setCustomLimit(limit); @@ -52,9 +55,14 @@ export const ActionProvider = ({ children }: { children: ReactNode }) => { const startGetText = () => setGetText(true); const stopGetText = () => setGetText(false); - const startGetList = () => setGetList(true); + const startGetList = () => { + setGetList(true); + socket?.emit('setGetList', { getList: true }); + } + const stopGetList = () => { setGetList(false); + socket?.emit('setGetList', { getList: false }); setPaginationType(''); setLimitType(''); setCustomLimit('');