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cAAc,EACdvB,SAAS,IAGf,GAIR,CAEA,MAAO,KACAZ,GAIDA,IAAqBK,EAAAA,GAAkBC,WAAWC,KAItDd,EAAoB,CAClBe,KAAMoB,EAAAA,EAAoClB,IAC1CC,QAAS,CACPkB,iBAAaK,EACbJ,OAAQC,EAAAA,EAAiCK,YAG7CzC,EAAqB,CACnBa,KAAMC,EAAAA,EAAkCC,IACxCC,QAAS,CACPwB,kBAAcD,EACdtB,aAASsB,KAGb3C,GAAmB,GAAM,CAhF3B,CAiFC,GACA,CAACS,EAAkBE,IAEf,IAAI,EAGAmC,GAAoCC,EAAAA,EAAAA,MAC/ClD,E","sources":["newelements/Casino/Games/__partials/fetch-updaters/FetchParamsUpdaterLastPlayedGames.tsx"],"sourcesContent":["import { memo, useLayoutEffect } from 'react';\nimport { useSelector } from 'react-redux';\nimport { recentPlayedParams } from 'utils/casino/casino';\nimport {\n CUSTOM_CATEGORIES,\n CUSTOM_CATEGORY_COMMAND_NAMES\n} from 'utils/constants/casino/custom-categories';\nimport {\n CasinoLastPlayedGamesResponse,\n ENewCasinoGamesFetchingParamsKey\n} from 'interfaces/new-casino';\nimport { swarmCommand } from 'services/get-swarm-data';\nimport { getLastPlayedCatSettings } from 'store/selectors/new-casino';\nimport { getIsLoggedIn } from 'store/selectors/user-data';\nimport { useSelectedCategory } from '../hooks/useSelectedCategory';\nimport { useCasinoGamesConditionalsValues } from '../providers/CasinoGamesConditionalsProvider';\nimport { useCasinoGamesConfigsValues } from '../providers/CasinoGamesConfigsContext';\nimport { useCasinoGamesFetchDisabledValues } from '../providers/CasinoGamesFetchDisabledContext';\nimport { useCasinoGamesFetchParamsValues } from '../providers/CasinoGamesFetchParamsContext';\nimport { CasinoGamesConditionalsActionType } from '../state/conditionals-reducer';\nimport { CasinoGamesFetchingParamsActionType } from '../state/reducer';\n\nconst _FetchParamsUpdaterLastPlayedGames = () => {\n const { configs } = useCasinoGamesConfigsValues();\n\n const { setIsFetchDisabled } = useCasinoGamesFetchDisabledValues();\n\n const { dispatchFetchParams } = useCasinoGamesFetchParamsValues();\n\n const { dispatchConditionals } = useCasinoGamesConditionalsValues();\n\n const lastPlayedCatSettings = useSelector(getLastPlayedCatSettings);\n const { selectedCategory } = useSelectedCategory({ configs });\n const isLoggedIn = useSelector(getIsLoggedIn);\n\n useLayoutEffect(() => {\n if (!selectedCategory) {\n return;\n }\n\n if (selectedCategory === CUSTOM_CATEGORIES.lastPlayed.id) {\n setIsFetchDisabled(true);\n dispatchConditionals({\n type: CasinoGamesConditionalsActionType.SET,\n payload: {\n loading: true\n }\n });\n const swarmLastPlayedGamesParams = recentPlayedParams(\n lastPlayedCatSettings.lastPlayedCatType\n );\n\n if (isLoggedIn) {\n swarmCommand(\n CUSTOM_CATEGORY_COMMAND_NAMES[CUSTOM_CATEGORIES.lastPlayed.id],\n swarmLastPlayedGamesParams,\n (response: CasinoLastPlayedGamesResponse) => {\n if (!response.details) {\n return;\n }\n\n const gameIds = response?.details?.game_ids?.map(\n idObject => idObject._id\n );\n\n if (gameIds.length) {\n dispatchFetchParams({\n type: CasinoGamesFetchingParamsActionType.SET,\n payload: {\n external_id: gameIds,\n by_key: ENewCasinoGamesFetchingParamsKey.Id,\n category: undefined\n }\n });\n setIsFetchDisabled(false);\n dispatchConditionals({\n type: CasinoGamesConditionalsActionType.SET,\n payload: {\n loading: undefined\n }\n });\n } else {\n dispatchConditionals({\n type: CasinoGamesConditionalsActionType.SET,\n payload: {\n emptyResults: true,\n loading: false\n }\n });\n }\n }\n );\n }\n }\n\n return () => {\n if (!selectedCategory) {\n return;\n }\n\n if (selectedCategory !== CUSTOM_CATEGORIES.lastPlayed.id) {\n return;\n }\n\n dispatchFetchParams({\n type: CasinoGamesFetchingParamsActionType.SET,\n payload: {\n external_id: undefined,\n by_key: ENewCasinoGamesFetchingParamsKey.Category\n }\n });\n dispatchConditionals({\n type: CasinoGamesConditionalsActionType.SET,\n payload: {\n emptyResults: undefined,\n loading: undefined\n }\n });\n setIsFetchDisabled(false);\n };\n }, [selectedCategory, isLoggedIn]);\n\n return null;\n};\n\nexport const FetchParamsUpdaterLastPlayedGames = memo(\n _FetchParamsUpdaterLastPlayedGames\n);\n"],"names":["_FetchParamsUpdaterLastPlayedGames","configs","useCasinoGamesConfigsValues","setIsFetchDisabled","useCasinoGamesFetchDisabledValues","dispatchFetchParams","useCasinoGamesFetchParamsValues","dispatchConditionals","useCasinoGamesConditionalsValues","lastPlayedCatSettings","useSelector","getLastPlayedCatSettings","selectedCategory","useSelectedCategory","isLoggedIn","getIsLoggedIn","useLayoutEffect","CUSTOM_CATEGORIES","lastPlayed","id","type","CasinoGamesConditionalsActionType","SET","payload","loading","swarmLastPlayedGamesParams","recentPlayedParams","lastPlayedCatType","swarmCommand","CUSTOM_CATEGORY_COMMAND_NAMES","response","_response$details","_response$details$gam","details","gameIds","game_ids","map","idObject","_id","length","CasinoGamesFetchingParamsActionType","external_id","by_key","ENewCasinoGamesFetchingParamsKey","Id","category","undefined","emptyResults","Category","FetchParamsUpdaterLastPlayedGames","memo"],"sourceRoot":""}