@ludo.ninja/components 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api/graphql/index.js +3 -7
- package/build/api/server-assets/mutations/useDislikeAsset/index.js +7 -9
- package/build/api/server-assets/mutations/useLikeAsset/index.js +7 -9
- package/build/api/server-assets/queries/useFetchAssetByBlockchain/index.js +14 -21
- package/build/api/server-assets/queries/useFetchAssets/index.js +11 -14
- package/build/api/server-assets/queries/useFetchDynamicAssetLikes/index.js +13 -15
- package/build/api/server-assets/queries/useFetchDynamicAssetsLikes/index.js +11 -13
- package/build/api/server-collection/mutations/useDislikeCollection/index.js +7 -9
- package/build/api/server-collection/mutations/useLikeCollection/index.js +7 -9
- package/build/api/server-experiences/queries/useFetchMyExperienceWithLevel/index.js +19 -21
- package/build/api/server-experiences/queries/useFetchMyTasks/index.js +15 -20
- package/build/api/server-galleries/mutations/useAddAssetsToGallery/index.js +9 -12
- package/build/api/server-galleries/mutations/useAddChangeGalleryBanner/index.js +9 -13
- package/build/api/server-galleries/mutations/useAddCollectionsToGallery/index.js +9 -12
- package/build/api/server-galleries/mutations/useAddCreationsToGallery/index.js +13 -16
- package/build/api/server-galleries/mutations/useCreateFavorites/index.js +5 -8
- package/build/api/server-galleries/mutations/useCreateGallery/index.js +5 -8
- package/build/api/server-galleries/mutations/useDeleteGallery/index.js +10 -12
- package/build/api/server-galleries/mutations/useDeleteGalleryBanner/index.js +9 -13
- package/build/api/server-galleries/mutations/useEditGallery/index.js +5 -7
- package/build/api/server-galleries/mutations/useRemoveAssetFromGallery/index.js +13 -16
- package/build/api/server-galleries/mutations/useRemoveCollectionFromGallery/index.js +12 -15
- package/build/api/server-galleries/queries/useFetchGallery/index.js +11 -18
- package/build/api/server-galleries/queries/useFetchGalleryAssets/index.js +9 -12
- package/build/api/server-galleries/queries/useFetchMyFavorites/index.js +11 -17
- package/build/api/server-galleries/queries/useFetchMyGalleries/index.js +13 -19
- package/build/api/server-galleries/queries/useFetchSubscribedGalleries/index.js +9 -11
- package/build/api/server-galleries/queries/useFetchUserFavorites/index.js +10 -16
- package/build/api/server-identities/mutations/useAddWalletElrond/index.js +10 -12
- package/build/api/server-identities/mutations/useAddWalletFlow/index.js +10 -12
- package/build/api/server-identities/mutations/useAddWalletMetamask/index.js +10 -12
- package/build/api/server-identities/mutations/useAddWalletSolana/index.js +10 -12
- package/build/api/server-identities/mutations/useAddWalletTezos/index.js +10 -12
- package/build/api/server-identities/mutations/useFollowProfile/index.js +13 -15
- package/build/api/server-identities/mutations/useGenerateNewInviteCodes/index.js +7 -9
- package/build/api/server-identities/mutations/useInviteCode/index.js +9 -11
- package/build/api/server-identities/mutations/useRemoveWallet/index.js +10 -12
- package/build/api/server-identities/mutations/useRevokeToken/index.js +5 -7
- package/build/api/server-identities/mutations/useSaveEmailOfJoiner/index.js +9 -11
- package/build/api/server-identities/mutations/useUnfollowProfile/index.js +13 -15
- package/build/api/server-identities/queries/useFetchProfile/index.js +19 -23
- package/build/api/server-identities/queries/useFetchUserWallets/index.js +4 -6
- package/build/api/server-medias/mutations/useDeleteUserpic/index.js +7 -9
- package/build/api/server-medias/mutations/useUploadUserpic/index.js +7 -9
- package/build/api/server-medias/queries/useFetchUserPic/index.js +8 -10
- package/build/api/server-opportunities/mutations/useDislikeOpportunity.js +8 -12
- package/build/api/server-opportunities/mutations/useLikeOpportunity.js +8 -12
- package/build/api/server-opportunities/mutations/useOpenOpportunity/index.js +8 -10
- package/build/api/server-opportunities/queries/useGetOpportunities.js +9 -13
- package/build/api/server-preferences/queries/fetchSearchResultSelections/index.js +6 -11
- package/build/api/server-preferences/queries/fetchSearchResultSelections/queryData.js +9 -13
- package/build/api/server-search/queries/useFetchAllCreations/index.js +15 -23
- package/build/api/server-search/queries/useFetchAssetsCount/index.js +2 -4
- package/build/api/server-search/queries/useFetchCollection/index.js +16 -23
- package/build/api/server-search/queries/useFetchCollections/index.js +16 -23
- package/build/api/server-search/queries/useFetchDynamicCollectionData/index.js +18 -24
- package/build/api/server-search/queries/useFetchFindAllTopEntitiesByName/index.js +16 -24
- package/build/api/server-search/queries/useFetchNetWorth/index.js +7 -9
- package/build/api/server-search/queries/useFindCreations/index.js +20 -28
- package/build/api/server-search/queries/useFindProfilesByName/index.js +14 -19
- package/build/api/server-search/queries/useFindShowcaseItems/index.js +1 -3
- package/build/api/server-search/queries/useFindUserCreations/index.js +16 -21
- package/build/api/server-search/queries/useFindUserShowcaseItems/index.js +1 -3
- package/build/api/subscriptions/SubscriberInviteNotification.js +18 -22
- package/build/components/assetPage/assetLikes/index.js +25 -30
- package/build/components/assetPage/assetNft/index.js +14 -21
- package/build/components/assetPage/audioVideoPlayer/Duration.js +5 -8
- package/build/components/assetPage/audioVideoPlayer/index.js +51 -81
- package/build/components/assetPage/category/index.js +18 -25
- package/build/components/assetPage/description/index.js +17 -24
- package/build/components/assetPage/index.js +11 -25
- package/build/components/assetPage/information/index.js +43 -50
- package/build/components/assetPage/marketPlaces/index.js +26 -33
- package/build/components/assetPage/media/AssetImage/index.js +52 -80
- package/build/components/assetPage/moreDropDown/index.js +47 -77
- package/build/components/assetPage/participants/index.js +64 -71
- package/build/components/assetPage/priceRank/index.js +38 -45
- package/build/components/assetPage/properties/index.js +19 -26
- package/build/components/assetPage/slider/index.js +44 -51
- package/build/components/assetPage/slider/slideItem.js +14 -21
- package/build/components/assetPage/slider/store.js +2 -5
- package/build/components/assetPage/tittle/index.js +32 -39
- package/build/components/assetPage/viewer3D/index.js +50 -58
- package/build/components/base/Meta/index.js +6 -11
- package/build/components/base/NoSSR/index.js +4 -9
- package/build/components/favoriteList/add/addCreationToFavoriteList/index.js +14 -19
- package/build/components/gallery/add/addCreationToGallery/index.js +20 -25
- package/build/components/headers/components/headerExperienceLabel/index.js +12 -17
- package/build/components/headers/components/headerUserPic/index.js +11 -16
- package/build/components/headers/header/index.js +17 -22
- package/build/components/headers/headerSearch/index.js +21 -26
- package/build/components/headers/headerSimple/index.js +14 -19
- package/build/components/linkTabs/index.js +14 -19
- package/build/components/linkTabs/linkTab/index.js +22 -27
- package/build/components/profile/profileSkeleton/index.js +10 -18
- package/build/components/search/SearchInputContainer.js +61 -91
- package/build/components/search/searchCloseMoreButtons/index.js +20 -25
- package/build/components/search/searchSimpleInput/index.js +37 -65
- package/build/components/search/searchSuggestions/index.js +32 -37
- package/build/components/search/searchSuggestions/searchSuggestionsCaption/index.js +17 -22
- package/build/components/search/searchSuggestions/searchSuggestionsFooter/index.js +20 -25
- package/build/components/search/searchSuggestions/searchSuggestionsItem/index.js +29 -34
- package/build/components/search/searchSuggestions/searchSuggestionsItem/searchSuggestionsItemSkeleton/index.js +28 -58
- package/build/components/search/searchSuggestions/searchSuggestionsNotFound/index.js +19 -24
- package/build/components/searchFiltersConnector/filters/applyResetBtns/index.js +11 -16
- package/build/components/searchFiltersConnector/filters/galleriesFiltersForm/index.js +13 -18
- package/build/components/searchFiltersConnector/filters/index.js +38 -43
- package/build/components/searchFiltersConnector/filters/mobileFilters/index.js +5 -10
- package/build/components/searchFiltersConnector/filters/setsFiltersForm/index.js +12 -17
- package/build/components/searchFiltersConnector/index.js +12 -19
- package/build/components/sidebar/data.js +18 -26
- package/build/components/sidebar/index.js +59 -87
- package/build/components/sidebar/initializer.js +4 -34
- package/build/components/sidebar/sidebarFilters/index.js +8 -13
- package/build/components/sidebar/sidebarInviteCodeLabel/index.js +14 -19
- package/build/components/toTopBtn/index.js +32 -39
- package/build/dto/AssetEntity/index.js +19 -24
- package/build/dto/AssetEntity/interface.js +1 -2
- package/build/dto/AssetEntity/views/AssetAudio/index.js +11 -16
- package/build/dto/AssetEntity/views/AssetImage/index.js +12 -17
- package/build/dto/AssetEntity/views/AssetObject/index.js +13 -18
- package/build/dto/AssetEntity/views/AssetOther/index.js +13 -18
- package/build/dto/AssetEntity/views/AssetScreenshot/index.js +12 -17
- package/build/dto/AssetEntity/views/AssetVideo/index.js +11 -16
- package/build/dto/AssetEntity/views/index.js +6 -16
- package/build/dto/Collection/CollectionCreationEntity/index.js +22 -27
- package/build/dto/Collection/CollectionCreationEntity/interface.js +1 -2
- package/build/dto/Collection/CollectionEntity/index.js +5 -7
- package/build/dto/Collection/CollectionEntity/interface.js +1 -2
- package/build/dto/CreationEntity/index.js +19 -24
- package/build/dto/CreationEntity/interface.js +1 -2
- package/build/dto/GalleryEntityV2/index.js +5 -10
- package/build/dto/GalleryEntityV2/interface.js +1 -2
- package/build/dto/Theme/interface.js +1 -5
- package/build/dto/common/ItemType/data.js +26 -28
- package/build/dto/common/ItemType/index.js +5 -7
- package/build/dto/common/ItemViews/CreationAudio/index.js +11 -16
- package/build/dto/common/ItemViews/CreationImage/index.js +12 -17
- package/build/dto/common/ItemViews/CreationObject/index.js +10 -15
- package/build/dto/common/ItemViews/CreationOther/index.js +11 -16
- package/build/dto/common/ItemViews/CreationVideo/index.js +11 -16
- package/build/dto/common/Media/Audio/index.js +9 -14
- package/build/dto/common/Media/Image/index.js +10 -15
- package/build/dto/common/Media/Object/index.js +9 -14
- package/build/dto/common/Media/Other/index.js +14 -19
- package/build/dto/common/Media/Screenshot/index.js +10 -15
- package/build/dto/common/Media/Urls/index.js +23 -38
- package/build/dto/common/Media/Video/index.js +9 -14
- package/build/dto/common/Media/index.js +3 -5
- package/build/dto/common/Media/interface.js +1 -2
- package/build/entities/user/type.js +1 -2
- package/build/fonts/FontsInitializeLayout.js +13 -16
- package/build/fonts/vars.js +1 -6
- package/build/hooks/apollo/index.js +8 -11
- package/build/hooks/audio/useMultiAudio/index.js +10 -12
- package/build/hooks/extension/useExtension/index.js +8 -10
- package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.js +33 -39
- package/build/hooks/favorites/useGetUserFevoritesCreations/index.js +32 -39
- package/build/hooks/galleries/useGetUserGalleriesCreations/index.js +32 -39
- package/build/hooks/likes/dynamic/useFindCollectionsAndLikes.js +27 -34
- package/build/hooks/likes/dynamic/useFindCreationsAndLikes.js +26 -32
- package/build/hooks/likes/dynamic/useGetCollectionInfoAndLikes.js +23 -29
- package/build/hooks/likes/dynamic/useGetCreationsAndLikes.js +27 -34
- package/build/hooks/likes/dynamic/useGetCreationsAndLikesByType.js +30 -36
- package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.js +11 -13
- package/build/hooks/likes/dynamic/useGetTableLikes.js +24 -30
- package/build/hooks/likes/index.js +27 -32
- package/build/hooks/likes/useGetLikesAsset.js +20 -24
- package/build/layouts/GlobalLayout.js +24 -31
- package/build/layouts/base/LWithRegularHeader/index.js +7 -12
- package/build/layouts/base/LWithRegularHeader/type.js +1 -2
- package/build/layouts/base/LWithSearchHeader/index.js +5 -10
- package/build/layouts/base/LWithSearchHeader/type.js +1 -2
- package/build/layouts/custom/mainLayout/index.js +8 -13
- package/build/layouts/custom/styles.js +15 -21
- package/build/layouts/pageTransitionLayout.js +6 -8
- package/build/layouts/pageWithLayout.js +1 -2
- package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.js +35 -42
- package/build/modules/gallery/api/useGetFavoriteGallery.js +11 -15
- package/build/modules/gallery/store.js +10 -16
- package/build/modules/gallery/ui/AllResults.js +7 -11
- package/build/modules/gallery/ui/Description.js +24 -31
- package/build/modules/gallery/ui/EditGallery.js +15 -22
- package/build/modules/gallery/ui/GalleryDeleteIcon.js +12 -19
- package/build/modules/gallery/ui/PlaceholderItemsGallery.js +21 -28
- package/build/modules/gallery/ui/STopSections.js +10 -16
- package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.js +25 -30
- package/build/modules/gallery/ui/chooseGalleryItems/index.js +47 -52
- package/build/modules/gallery/ui/createGalleryForm/index.js +31 -36
- package/build/modules/gallery/ui/editGalleryForm/index.js +40 -45
- package/build/modules/gallery/ui/itemsPreview/index.js +54 -61
- package/build/modules/gallery/useToGalleryAsset.js +15 -23
- package/build/modules/notifications/CreatorNotifications.js +10 -40
- package/build/modules/notifications/index.js +3 -6
- package/build/modules/opportunity/OpportunityCard.js +81 -88
- package/build/modules/opportunity/OpportunityDropDown.js +11 -18
- package/build/modules/opportunity/ShareIcon.js +2 -6
- package/build/modules/opportunity/encodeQuery.js +4 -10
- package/build/modules/opportunity/popup/CopyIcon.js +3 -5
- package/build/modules/opportunity/popup/FacebookIcon.js +3 -5
- package/build/modules/opportunity/popup/LinkedInIcon.js +3 -5
- package/build/modules/opportunity/popup/LogoXIcon.js +3 -5
- package/build/modules/opportunity/popup/OpportunityMenu.js +44 -51
- package/build/modules/opportunity/type.js +1 -2
- package/build/modules/sessionScroll/globalTabs.js +1 -4
- package/build/modules/sessionScroll/index.js +16 -23
- package/build/modules/sessionScroll/type.js +1 -2
- package/build/modules/sessionScroll/useVirtuosoInitialScroll.js +12 -16
- package/build/modules/user/auth/useAuthVerification.js +10 -37
- package/build/modules/user/auth/useSignIn.js +7 -11
- package/build/modules/user/auth/useSignOut.js +11 -18
- package/build/modules/user/profileData/profileDataInitialization.js +14 -18
- package/build/modules/user/store.js +9 -12
- package/build/modules/virtuoso/VirtuosoPageBuilder.js +36 -43
- package/build/modules/virtuoso/VirtuosoToTopBtn.js +8 -13
- package/build/modules/virtuoso/types.js +1 -2
- package/build/modules/virtuoso/useSubscribeVirtuosoScrollToHeader.js +4 -8
- package/build/modules/virtuoso/useVirtuosoData.js +6 -10
- package/build/store/env/index.js +4 -7
- package/build/store/index.js +4 -7
- package/build/store/media/index.js +4 -7
- package/build/store/media/types.js +1 -2
- package/build/store/ui/index.js +21 -24
- package/build/store/ui/types.js +1 -2
- package/build/store/ui/utils.js +4 -8
- package/build/styles/ScreenWidth.js +3 -6
- package/build/styles/animations/index.js +3 -6
- package/build/styles/colors/index.js +1 -38
- package/build/styles/globalStyles.js +5 -7
- package/build/styles/mixins/boxShadow.js +3 -5
- package/build/styles/mixins/boxTransform.js +3 -5
- package/build/styles/mixins/z-indexes.js +10 -13
- package/build/styles/typography/index.js +1 -13
- package/build/system/ActiveLink/ActiveLink.test.js +14 -19
- package/build/system/ActiveLink/index.js +10 -38
- package/build/system/Alert/index.js +6 -11
- package/build/system/Alert/type.js +1 -8
- package/build/system/BasicOverlay/index.js +5 -10
- package/build/system/Buttons/IconButton/index.js +2 -7
- package/build/system/Buttons/IconWithButton/index.js +2 -7
- package/build/system/Buttons/MainButton/index.js +2 -7
- package/build/system/Buttons/SecondaryButton/index.js +2 -7
- package/build/system/Cards/CardCheckbox/CardCheckbox.test.js +8 -13
- package/build/system/Cards/CardCheckbox/index.js +19 -24
- package/build/system/Cards/CardContent/CardCategory/CardCategory.test.js +11 -16
- package/build/system/Cards/CardContent/CardCategory/index.js +13 -18
- package/build/system/Cards/CardContent/CardContent.test.js +31 -36
- package/build/system/Cards/CardContent/CardLikes/CardLikes.test.js +11 -16
- package/build/system/Cards/CardContent/CardLikes/index.js +11 -16
- package/build/system/Cards/CardContent/CardShowMore/CardShowMore.test.js +20 -25
- package/build/system/Cards/CardContent/CardShowMore/index.js +34 -40
- package/build/system/Cards/CardContent/index.js +32 -37
- package/build/system/Cards/CardMedia/CardAudio/CardAudio.test.js +35 -40
- package/build/system/Cards/CardMedia/CardAudio/index.js +18 -23
- package/build/system/Cards/CardMedia/CardImage/CardImage.test.js +14 -19
- package/build/system/Cards/CardMedia/CardImage/index.js +8 -13
- package/build/system/Cards/CardMedia/CardVideo/index.js +17 -22
- package/build/system/Cards/CardRank/index.js +32 -37
- package/build/system/Cards/CreationCard/CardHead.js +35 -42
- package/build/system/Cards/CreationCard/index.js +45 -76
- package/build/system/Cards/MultiMediaCard/index.js +30 -35
- package/build/system/Cards/Styles/Content.js +9 -14
- package/build/system/Cards/Styles/Head.js +8 -13
- package/build/system/Cards/Styles/Headicons.js +23 -28
- package/build/system/Cards/Styles/Image.js +8 -13
- package/build/system/Cards/Styles/Likes.js +14 -19
- package/build/system/Cards/Styles/MultiHead.js +11 -16
- package/build/system/Cards/Styles/Video.js +3 -8
- package/build/system/CardsHolderWithSkeleton/CardsHolder/CardsError/index.js +14 -19
- package/build/system/CardsHolderWithSkeleton/CardsHolder/CardsNoResults/index.js +10 -15
- package/build/system/CardsHolderWithSkeleton/CardsHolder/CardsSkeleton/index.js +17 -24
- package/build/system/CardsHolderWithSkeleton/CardsHolderLoader/index.js +15 -20
- package/build/system/DropDown/DropDown.test.js +14 -19
- package/build/system/DropDown/index.js +12 -17
- package/build/system/Filters/helpers.js +1 -5
- package/build/system/Filters/type.js +2 -5
- package/build/system/Forms/Checkbox/Checkbox.test.js +13 -18
- package/build/system/Forms/Checkbox/index.js +16 -21
- package/build/system/Forms/DatePicker/index.js +46 -51
- package/build/system/Forms/ErrorLabel/ErrorLabel.test.js +11 -16
- package/build/system/Forms/ErrorLabel/index.js +10 -15
- package/build/system/Forms/Input/Input.test.js +13 -18
- package/build/system/Forms/Input/index.js +29 -35
- package/build/system/Forms/Input/type.js +1 -2
- package/build/system/Forms/Messages/index.js +1 -3
- package/build/system/Forms/RadioInput/index.js +12 -17
- package/build/system/Forms/Selects/DesktopSelect/index.js +41 -69
- package/build/system/Forms/Selects/DesktopSelect/type.js +1 -2
- package/build/system/Forms/Selects/MobileSelect/index.js +10 -15
- package/build/system/Forms/TextArea/TextArea.test.js +13 -18
- package/build/system/Forms/TextArea/index.js +26 -31
- package/build/system/Forms/index.js +5 -14
- package/build/system/Img/ExternalImage/index.js +11 -17
- package/build/system/Img/ImageInterceptor/ImageInterceptor.test.js +18 -23
- package/build/system/Img/ImageInterceptor/index.js +10 -40
- package/build/system/Img/Profilepic/index.js +12 -19
- package/build/system/Img/Userpic/UserPic.test.js +15 -20
- package/build/system/Img/Userpic/index.js +28 -33
- package/build/system/Img/index.js +3 -19
- package/build/system/Labels/ExperienceLabel/ExperienceLabel.test.js +12 -17
- package/build/system/Labels/ExperienceLabel/index.js +27 -32
- package/build/system/Labels/InviteLabel/InviteLabel.test.js +10 -15
- package/build/system/Labels/InviteLabel/index.js +14 -19
- package/build/system/Labels/SkeletonLabel/index.js +2 -7
- package/build/system/Modals/Modal/Modal.test.js +11 -16
- package/build/system/Modals/Modal/index.js +24 -29
- package/build/system/Modals/ModalSidebar/CreatorModalSidebarPortal.js +7 -37
- package/build/system/Modals/ModalSidebar/ModalSidebar.test.js +11 -16
- package/build/system/Modals/ModalSidebar/ModalSidebarPortal.js +5 -9
- package/build/system/Modals/ModalSidebar/index.js +23 -29
- package/build/system/Overlay/Overlay.test.js +11 -16
- package/build/system/Overlay/index.js +11 -16
- package/build/system/PageLoader/index.js +2 -7
- package/build/system/Palete/index.js +2 -7
- package/build/system/ShareIconResize.js +14 -21
- package/build/system/Tabs/TabNavLink/TabNavLink.test.js +15 -20
- package/build/system/Tabs/TabNavLink/index.js +17 -23
- package/build/system/Tabs/TabsNav/TabsNav.test.js +18 -23
- package/build/system/Tabs/TabsNav/index.js +7 -13
- package/build/system/Tabs/TabsNav/type.js +1 -2
- package/build/system/Tabs/TabsPanel/TabsPanel.test.js +13 -18
- package/build/system/Tabs/TabsPanel/index.js +5 -10
- package/build/system/index.js +6 -22
- package/build/system/theme.js +1 -7
- package/build/utils/3d.js +1 -5
- package/build/utils/adaptive/check4k.js +5 -9
- package/build/utils/adaptive/scale.js +5 -9
- package/build/utils/auth/index.js +3 -7
- package/build/utils/copyBtn/index.js +23 -30
- package/build/utils/env/index.js +1 -5
- package/build/utils/extractItemIds.js +3 -9
- package/build/utils/getDimensionsImage.js +1 -5
- package/build/utils/getPageSizeAssets.js +4 -8
- package/build/utils/imageProportionsSize/index.js +1 -5
- package/build/utils/screen/index.js +24 -30
- package/build/utils/seacrhTabs.js +1 -4
- package/build/utils/ssrFunctions/index.js +9 -15
- package/build/utils/ui/index.js +1 -5
- package/package.json +1 -1
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const utils_1 = require("@ludo.ninja/utils");
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { eventsTypes, sendEventToExtension } from '@ludo.ninja/utils';
|
|
5
3
|
const useExtension = () => {
|
|
6
|
-
const [isExtensionInstalled, setIsExtensionInstalled] =
|
|
7
|
-
const pingExtension =
|
|
4
|
+
const [isExtensionInstalled, setIsExtensionInstalled] = useState(false);
|
|
5
|
+
const pingExtension = useCallback(async () => {
|
|
8
6
|
try {
|
|
9
|
-
const response = (await
|
|
7
|
+
const response = (await sendEventToExtension(eventsTypes.pingVersion));
|
|
10
8
|
setIsExtensionInstalled(Boolean(response?.version));
|
|
11
9
|
}
|
|
12
10
|
catch (e) {
|
|
13
11
|
setIsExtensionInstalled(false);
|
|
14
12
|
}
|
|
15
13
|
}, [setIsExtensionInstalled]);
|
|
16
|
-
|
|
14
|
+
useEffect(() => {
|
|
17
15
|
pingExtension();
|
|
18
16
|
}, []);
|
|
19
17
|
return {
|
|
@@ -23,9 +21,9 @@ const useExtension = () => {
|
|
|
23
21
|
pingExtension,
|
|
24
22
|
};
|
|
25
23
|
};
|
|
26
|
-
|
|
24
|
+
export default useExtension;
|
|
27
25
|
const openExtension = () => {
|
|
28
|
-
|
|
26
|
+
sendEventToExtension(eventsTypes.openExtension);
|
|
29
27
|
};
|
|
30
28
|
const openExtensionChromeStorePage = () => {
|
|
31
29
|
window.open('https://chromewebstore.google.com/detail/ludo-x/fgcmebogmgdheonhhefnblfodobpmfip', '_blank');
|
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
13
|
-
const ui_1 = require("../../../store/ui");
|
|
14
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
15
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
16
|
-
const GalleryEntityV2_1 = __importDefault(require("../../../dto/GalleryEntityV2"));
|
|
17
|
-
const useGetUserFevoritesCreations_1 = require("../useGetUserFevoritesCreations");
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useLazyQuery, useQuery } from '@apollo/client';
|
|
3
|
+
import { hosts } from '@ludo.ninja/api';
|
|
4
|
+
import { FetchGalleryV2Document, } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
|
|
5
|
+
import { FetchAssetsDocument, FetchCollectionsByIdsDocument, } from '@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema';
|
|
6
|
+
import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
|
|
7
|
+
import { useUiStore } from "../../../store/ui";
|
|
8
|
+
import CollectionCreationEntity from "../../../dto/Collection/CollectionCreationEntity";
|
|
9
|
+
import CreationEntity from "../../../dto/CreationEntity";
|
|
10
|
+
import GalleryEntityV2 from "../../../dto/GalleryEntityV2";
|
|
11
|
+
import { getMediaForGallery } from '../useGetUserFevoritesCreations';
|
|
18
12
|
const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
19
|
-
const [gallery, setGallery] =
|
|
20
|
-
const [assets, setAssets] =
|
|
21
|
-
const [collections, setCollections] =
|
|
22
|
-
const [currentPage, setCurrentPage] =
|
|
23
|
-
const [loading, setLoading] =
|
|
24
|
-
const [fetchError, setFetchError] =
|
|
25
|
-
const [allResults, setAllResults] =
|
|
26
|
-
const openAlert =
|
|
27
|
-
const { error: galleryError, loading: galleryLoading, refetch, } =
|
|
13
|
+
const [gallery, setGallery] = useState([]);
|
|
14
|
+
const [assets, setAssets] = useState(null);
|
|
15
|
+
const [collections, setCollections] = useState(null);
|
|
16
|
+
const [currentPage, setCurrentPage] = useState(1);
|
|
17
|
+
const [loading, setLoading] = useState(true);
|
|
18
|
+
const [fetchError, setFetchError] = useState(false);
|
|
19
|
+
const [allResults, setAllResults] = useState(null);
|
|
20
|
+
const openAlert = useUiStore((state) => state.openAlert);
|
|
21
|
+
const { error: galleryError, loading: galleryLoading, refetch, } = useQuery(FetchGalleryV2Document, {
|
|
28
22
|
variables: { galleryId },
|
|
29
23
|
context: {
|
|
30
|
-
uri:
|
|
24
|
+
uri: hosts.galleriesHost,
|
|
31
25
|
},
|
|
32
26
|
notifyOnNetworkStatusChange: true,
|
|
33
27
|
fetchPolicy: 'no-cache',
|
|
34
28
|
onCompleted: ({ fetchGalleryV2 }) => {
|
|
35
|
-
setGallery([new
|
|
29
|
+
setGallery([new GalleryEntityV2(fetchGalleryV2)]);
|
|
36
30
|
setAllResults(fetchGalleryV2.items);
|
|
37
31
|
},
|
|
38
32
|
onError: () => {
|
|
@@ -42,13 +36,13 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
42
36
|
setAllResults(0);
|
|
43
37
|
},
|
|
44
38
|
});
|
|
45
|
-
const [fetchAssets, { loading: assetsLoading, error: assetsError }] =
|
|
46
|
-
context: { uri:
|
|
39
|
+
const [fetchAssets, { loading: assetsLoading, error: assetsError }] = useLazyQuery(FetchAssetsDocument, {
|
|
40
|
+
context: { uri: hosts.searchHost },
|
|
47
41
|
fetchPolicy: 'no-cache',
|
|
48
42
|
onCompleted: ({ fetchAssets: data }) => {
|
|
49
43
|
setAssets((prevAssets) => [
|
|
50
44
|
...(prevAssets || []),
|
|
51
|
-
...data.map((asset) => new
|
|
45
|
+
...data.map((asset) => new CreationEntity({
|
|
52
46
|
...asset,
|
|
53
47
|
itemType: 'asset',
|
|
54
48
|
itemId: asset.assetId,
|
|
@@ -57,34 +51,34 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
57
51
|
},
|
|
58
52
|
onError: () => {
|
|
59
53
|
openAlert({
|
|
60
|
-
type:
|
|
54
|
+
type: alertVariants.error,
|
|
61
55
|
caption: 'Oops, something went wrong.',
|
|
62
56
|
});
|
|
63
57
|
setAssets([]);
|
|
64
58
|
setFetchError(true);
|
|
65
59
|
},
|
|
66
60
|
});
|
|
67
|
-
const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] =
|
|
68
|
-
context: { uri:
|
|
61
|
+
const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] = useLazyQuery(FetchCollectionsByIdsDocument, {
|
|
62
|
+
context: { uri: hosts.searchHost },
|
|
69
63
|
fetchPolicy: 'no-cache',
|
|
70
64
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
71
65
|
setCollections((prevCollections) => [
|
|
72
66
|
...(prevCollections || []),
|
|
73
|
-
...data.map((collection) => new
|
|
67
|
+
...data.map((collection) => new CollectionCreationEntity(collection, 'collection')),
|
|
74
68
|
]);
|
|
75
69
|
},
|
|
76
70
|
onError: () => {
|
|
77
71
|
openAlert({
|
|
78
|
-
type:
|
|
72
|
+
type: alertVariants.error,
|
|
79
73
|
caption: 'Oops, something went wrong.',
|
|
80
74
|
});
|
|
81
75
|
setCollections([]);
|
|
82
76
|
setFetchError(true);
|
|
83
77
|
},
|
|
84
78
|
});
|
|
85
|
-
|
|
79
|
+
useEffect(() => {
|
|
86
80
|
if (gallery && gallery.length > 0) {
|
|
87
|
-
const { assetArray, collectionsArray } =
|
|
81
|
+
const { assetArray, collectionsArray } = getMediaForGallery(gallery, false, currentPage, itemsCount);
|
|
88
82
|
const assetPromise = assetArray.length > 0
|
|
89
83
|
? fetchAssets({ variables: { assetIds: assetArray } })
|
|
90
84
|
: Promise.resolve();
|
|
@@ -129,4 +123,4 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
129
123
|
loadMore,
|
|
130
124
|
};
|
|
131
125
|
};
|
|
132
|
-
|
|
126
|
+
export { useGetFavoriteGallaryCreations };
|
|
@@ -1,55 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
|
|
12
|
-
const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
13
|
-
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
14
|
-
const ui_1 = require("../../../store/ui");
|
|
15
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
16
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
17
|
-
const GalleryEntityV2_1 = __importDefault(require("../../../dto/GalleryEntityV2"));
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useLazyQuery, useQuery } from '@apollo/client';
|
|
3
|
+
import { hosts } from '@ludo.ninja/api';
|
|
4
|
+
import { FetchUserFavoritesV2Document, } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
|
|
5
|
+
import { FetchAssetsDocument, FetchCollectionsByIdsDocument, } from '@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema';
|
|
6
|
+
import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
|
|
7
|
+
import { useUiStore } from "../../../store/ui";
|
|
8
|
+
import CollectionCreationEntity from "../../../dto/Collection/CollectionCreationEntity";
|
|
9
|
+
import CreationEntity from "../../../dto/CreationEntity";
|
|
10
|
+
import GalleryEntityV2 from "../../../dto/GalleryEntityV2";
|
|
18
11
|
const maxUserFavoritesLength = 1000;
|
|
19
12
|
const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
20
|
-
const [assets, setAsset] =
|
|
21
|
-
const [collections, setCollections] =
|
|
22
|
-
const [favorites, setFavorites] =
|
|
23
|
-
const [loading, setLoading] =
|
|
24
|
-
const openAlert =
|
|
25
|
-
const nextPageToken =
|
|
26
|
-
const [isNextLoading, setIsNextLoading] =
|
|
13
|
+
const [assets, setAsset] = useState(null);
|
|
14
|
+
const [collections, setCollections] = useState(null);
|
|
15
|
+
const [favorites, setFavorites] = useState([]);
|
|
16
|
+
const [loading, setLoading] = useState(true);
|
|
17
|
+
const openAlert = useUiStore((state) => state.openAlert);
|
|
18
|
+
const nextPageToken = useRef(null);
|
|
19
|
+
const [isNextLoading, setIsNextLoading] = useState(false); // todo: after update api , get isNextPage from results
|
|
27
20
|
// const isHaveNextPage = favorites.length < results;
|
|
28
21
|
const isHaveNextPage = !!nextPageToken.current;
|
|
29
|
-
const { loading: favoritesLoading, error: favoritesError, refetch, fetchMore, } =
|
|
30
|
-
context: { uri:
|
|
22
|
+
const { loading: favoritesLoading, error: favoritesError, refetch, fetchMore, } = useQuery(FetchUserFavoritesV2Document, {
|
|
23
|
+
context: { uri: hosts.galleriesHost }, //todo : update variables to object page
|
|
31
24
|
variables: { pageSize, userId, pageToken },
|
|
32
25
|
fetchPolicy: 'no-cache',
|
|
33
26
|
onCompleted: ({ fetchUserFavoritesV2: { galleries, nextPageToken: token }, }) => {
|
|
34
27
|
// nextPageToken.current = nextPage.nextPage?.token || null;
|
|
35
28
|
nextPageToken.current = token || null;
|
|
36
|
-
setFavorites(galleries.map((gallery) => new
|
|
29
|
+
setFavorites(galleries.map((gallery) => new GalleryEntityV2(gallery)));
|
|
37
30
|
setLoading(false);
|
|
38
31
|
},
|
|
39
32
|
onError: () => {
|
|
40
33
|
openAlert({
|
|
41
|
-
type:
|
|
34
|
+
type: alertVariants.error,
|
|
42
35
|
caption: 'Oops, something went wrong while fetching favorites.',
|
|
43
36
|
});
|
|
44
37
|
setFavorites([]);
|
|
45
38
|
setLoading(false);
|
|
46
39
|
},
|
|
47
40
|
});
|
|
48
|
-
const [fetchAssets, { loading: assetsLoading, error: assetsError }] =
|
|
49
|
-
context: { uri:
|
|
41
|
+
const [fetchAssets, { loading: assetsLoading, error: assetsError }] = useLazyQuery(FetchAssetsDocument, {
|
|
42
|
+
context: { uri: hosts.searchHost },
|
|
50
43
|
fetchPolicy: 'no-cache',
|
|
51
44
|
onCompleted: ({ fetchAssets: data }) => {
|
|
52
|
-
setAsset(data.map((asset) => new
|
|
45
|
+
setAsset(data.map((asset) => new CreationEntity({
|
|
53
46
|
...asset,
|
|
54
47
|
itemType: 'asset',
|
|
55
48
|
itemId: asset.assetId,
|
|
@@ -58,30 +51,30 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
58
51
|
},
|
|
59
52
|
onError: () => {
|
|
60
53
|
openAlert({
|
|
61
|
-
type:
|
|
54
|
+
type: alertVariants.error,
|
|
62
55
|
caption: 'Oops, something went wrong.',
|
|
63
56
|
});
|
|
64
57
|
setAsset(null);
|
|
65
58
|
setLoading(false);
|
|
66
59
|
},
|
|
67
60
|
});
|
|
68
|
-
const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] =
|
|
69
|
-
context: { uri:
|
|
61
|
+
const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] = useLazyQuery(FetchCollectionsByIdsDocument, {
|
|
62
|
+
context: { uri: hosts.searchHost },
|
|
70
63
|
fetchPolicy: 'no-cache',
|
|
71
64
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
72
|
-
setCollections(data.map((collection) => new
|
|
65
|
+
setCollections(data.map((collection) => new CollectionCreationEntity(collection)));
|
|
73
66
|
setLoading(false);
|
|
74
67
|
},
|
|
75
68
|
onError: () => {
|
|
76
69
|
openAlert({
|
|
77
|
-
type:
|
|
70
|
+
type: alertVariants.error,
|
|
78
71
|
caption: 'Oops, something went wrong.',
|
|
79
72
|
});
|
|
80
73
|
setCollections(null);
|
|
81
74
|
setLoading(false);
|
|
82
75
|
},
|
|
83
76
|
});
|
|
84
|
-
|
|
77
|
+
useEffect(() => {
|
|
85
78
|
if (favorites.length > 0) {
|
|
86
79
|
const { assetArray, collectionsArray } = getMediaForGallery(favorites, true);
|
|
87
80
|
if (assetArray.length > 0) {
|
|
@@ -152,8 +145,8 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
152
145
|
isNextLoading,
|
|
153
146
|
};
|
|
154
147
|
};
|
|
155
|
-
|
|
156
|
-
function getMediaForGallery(favorites, takeFirstFour, pageNumber = 1, totalLength) {
|
|
148
|
+
export { useGetUserFevoritesCreations };
|
|
149
|
+
export function getMediaForGallery(favorites, takeFirstFour, pageNumber = 1, totalLength) {
|
|
157
150
|
if (favorites.length === 0)
|
|
158
151
|
return { assetArray: [], collectionsArray: [] };
|
|
159
152
|
const itemsPerPage = 40;
|
|
@@ -1,55 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
|
|
12
|
-
const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
13
|
-
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
14
|
-
const ui_1 = require("../../../store/ui");
|
|
15
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
16
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
17
|
-
const GalleryEntityV2_1 = __importDefault(require("../../../dto/GalleryEntityV2"));
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useLazyQuery, useQuery } from '@apollo/client';
|
|
3
|
+
import { hosts } from '@ludo.ninja/api';
|
|
4
|
+
import { FetchUserGalleriesV2Document, } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
|
|
5
|
+
import { FetchAssetsDocument, FetchCollectionsByIdsDocument, } from '@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema';
|
|
6
|
+
import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
|
|
7
|
+
import { useUiStore } from "../../../store/ui";
|
|
8
|
+
import CollectionCreationEntity from "../../../dto/Collection/CollectionCreationEntity";
|
|
9
|
+
import CreationEntity from "../../../dto/CreationEntity";
|
|
10
|
+
import GalleryEntityV2 from "../../../dto/GalleryEntityV2";
|
|
18
11
|
const maxUserFavoritesLength = 1000;
|
|
19
12
|
const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
20
|
-
const [assets, setAsset] =
|
|
21
|
-
const [collections, setCollections] =
|
|
22
|
-
const [galleries, setGalleries] =
|
|
23
|
-
const [loading, setLoading] =
|
|
24
|
-
const openAlert =
|
|
25
|
-
const nextPageToken =
|
|
26
|
-
const [isNextLoading, setIsNextLoading] =
|
|
13
|
+
const [assets, setAsset] = useState(null);
|
|
14
|
+
const [collections, setCollections] = useState(null);
|
|
15
|
+
const [galleries, setGalleries] = useState([]);
|
|
16
|
+
const [loading, setLoading] = useState(true);
|
|
17
|
+
const openAlert = useUiStore((state) => state.openAlert);
|
|
18
|
+
const nextPageToken = useRef(null);
|
|
19
|
+
const [isNextLoading, setIsNextLoading] = useState(false); // todo: after update api , get isNextPage from results
|
|
27
20
|
// const isHaveNextPage = favorites.length < results;
|
|
28
21
|
const isHaveNextPage = !!nextPageToken.current;
|
|
29
|
-
const { loading: favoritesLoading, error: galleriesError, refetch, fetchMore, } =
|
|
30
|
-
context: { uri:
|
|
22
|
+
const { loading: favoritesLoading, error: galleriesError, refetch, fetchMore, } = useQuery(FetchUserGalleriesV2Document, {
|
|
23
|
+
context: { uri: hosts.galleriesHost },
|
|
31
24
|
variables: { pageSize, userId, pageToken },
|
|
32
25
|
fetchPolicy: 'no-cache',
|
|
33
26
|
onCompleted: ({ fetchUserGalleriesV2: { galleries, nextPageToken: token }, }) => {
|
|
34
27
|
// nextPageToken.current = nextPage.nextPage?.token || null;
|
|
35
28
|
nextPageToken.current = token || null;
|
|
36
|
-
setGalleries(galleries.map((gallery) => new
|
|
29
|
+
setGalleries(galleries.map((gallery) => new GalleryEntityV2(gallery)));
|
|
37
30
|
setLoading(false);
|
|
38
31
|
},
|
|
39
32
|
onError: () => {
|
|
40
33
|
openAlert({
|
|
41
|
-
type:
|
|
34
|
+
type: alertVariants.error,
|
|
42
35
|
caption: 'Oops, something went wrong while fetching galleries.',
|
|
43
36
|
});
|
|
44
37
|
setGalleries([]);
|
|
45
38
|
setLoading(false);
|
|
46
39
|
},
|
|
47
40
|
});
|
|
48
|
-
const [fetchAssets, { loading: assetsLoading, error: assetsError }] =
|
|
49
|
-
context: { uri:
|
|
41
|
+
const [fetchAssets, { loading: assetsLoading, error: assetsError }] = useLazyQuery(FetchAssetsDocument, {
|
|
42
|
+
context: { uri: hosts.searchHost },
|
|
50
43
|
fetchPolicy: 'no-cache',
|
|
51
44
|
onCompleted: ({ fetchAssets: data }) => {
|
|
52
|
-
setAsset(data.map((asset) => new
|
|
45
|
+
setAsset(data.map((asset) => new CreationEntity({
|
|
53
46
|
...asset,
|
|
54
47
|
itemType: 'asset',
|
|
55
48
|
itemId: asset.assetId,
|
|
@@ -58,30 +51,30 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
58
51
|
},
|
|
59
52
|
onError: () => {
|
|
60
53
|
openAlert({
|
|
61
|
-
type:
|
|
54
|
+
type: alertVariants.error,
|
|
62
55
|
caption: 'Oops, something went wrong.',
|
|
63
56
|
});
|
|
64
57
|
setAsset(null);
|
|
65
58
|
setLoading(false);
|
|
66
59
|
},
|
|
67
60
|
});
|
|
68
|
-
const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] =
|
|
69
|
-
context: { uri:
|
|
61
|
+
const [fetchCollections, { loading: collectionsLoading, error: collectionsError },] = useLazyQuery(FetchCollectionsByIdsDocument, {
|
|
62
|
+
context: { uri: hosts.searchHost },
|
|
70
63
|
fetchPolicy: 'no-cache',
|
|
71
64
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
72
|
-
setCollections(data.map((collection) => new
|
|
65
|
+
setCollections(data.map((collection) => new CollectionCreationEntity(collection)));
|
|
73
66
|
setLoading(false);
|
|
74
67
|
},
|
|
75
68
|
onError: () => {
|
|
76
69
|
openAlert({
|
|
77
|
-
type:
|
|
70
|
+
type: alertVariants.error,
|
|
78
71
|
caption: 'Oops, something went wrong.',
|
|
79
72
|
});
|
|
80
73
|
setCollections(null);
|
|
81
74
|
setLoading(false);
|
|
82
75
|
},
|
|
83
76
|
});
|
|
84
|
-
|
|
77
|
+
useEffect(() => {
|
|
85
78
|
if (galleries.length > 0) {
|
|
86
79
|
const { assetArray, collectionsArray } = getMediaForGallery(galleries, true);
|
|
87
80
|
if (assetArray.length > 0) {
|
|
@@ -144,8 +137,8 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
144
137
|
isNextLoading,
|
|
145
138
|
};
|
|
146
139
|
};
|
|
147
|
-
|
|
148
|
-
function getMediaForGallery(favorites, takeFirstFour) {
|
|
140
|
+
export { useGetUserGalleriesCreations };
|
|
141
|
+
export function getMediaForGallery(favorites, takeFirstFour) {
|
|
149
142
|
if (favorites.length === 0)
|
|
150
143
|
return { assetArray: [], collectionsArray: [] };
|
|
151
144
|
const assetArray = [];
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const api_1 = require("@ludo.ninja/api");
|
|
10
|
-
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
11
|
-
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
12
|
-
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
13
|
-
const ui_1 = require("../../../store/ui");
|
|
14
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useLazyQuery } from '@apollo/client';
|
|
3
|
+
import { hosts } from '@ludo.ninja/api';
|
|
4
|
+
import { FetchDynamicCollectionsDataDocument, useFindCollectionsQuery, } from '@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema';
|
|
5
|
+
import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
|
|
6
|
+
import { extractItemIds } from "./useGetCreationsAndLikes";
|
|
7
|
+
import { useUiStore } from "../../../store/ui";
|
|
8
|
+
import CollectionCreationEntity from "../../../dto/Collection/CollectionCreationEntity";
|
|
15
9
|
// export const prefetchFindCollections = (
|
|
16
10
|
// { term, input, pageSize, pageToken }: schema.IQueryFindCollectionsArgs,
|
|
17
11
|
// apolloClient: ApolloClient<NormalizedCacheObject>
|
|
@@ -30,17 +24,17 @@ const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collect
|
|
|
30
24
|
// });
|
|
31
25
|
// };
|
|
32
26
|
const maxCollectionsLength = 1000;
|
|
33
|
-
const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
34
|
-
const [collections, setCollections] =
|
|
35
|
-
const [nextPageToken, setNextPageToken] =
|
|
36
|
-
const [results, setResults] =
|
|
37
|
-
const openAlert =
|
|
38
|
-
const [collectionsLikes, setCollectionsLikes] =
|
|
39
|
-
const [loading, setLoading] =
|
|
40
|
-
const { error, loading: collectionsLoading, fetchMore, refetch, } =
|
|
27
|
+
export const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
28
|
+
const [collections, setCollections] = useState([]);
|
|
29
|
+
const [nextPageToken, setNextPageToken] = useState(null);
|
|
30
|
+
const [results, setResults] = useState(0);
|
|
31
|
+
const openAlert = useUiStore((state) => state.openAlert);
|
|
32
|
+
const [collectionsLikes, setCollectionsLikes] = useState([]);
|
|
33
|
+
const [loading, setLoading] = useState(true);
|
|
34
|
+
const { error, loading: collectionsLoading, fetchMore, refetch, } = useFindCollectionsQuery({
|
|
41
35
|
fetchPolicy: 'no-cache',
|
|
42
36
|
context: {
|
|
43
|
-
uri:
|
|
37
|
+
uri: hosts.searchHost,
|
|
44
38
|
},
|
|
45
39
|
variables: {
|
|
46
40
|
term,
|
|
@@ -48,7 +42,7 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
48
42
|
page,
|
|
49
43
|
},
|
|
50
44
|
onCompleted: ({ findCollections: { collections, ...nextPage } }) => {
|
|
51
|
-
setCollections(collections.map((collection) => new
|
|
45
|
+
setCollections(collections.map((collection) => new CollectionCreationEntity({
|
|
52
46
|
...collection,
|
|
53
47
|
name: collection && collection.collectionTitle,
|
|
54
48
|
}, 'collection')));
|
|
@@ -60,15 +54,15 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
60
54
|
},
|
|
61
55
|
onError: () => {
|
|
62
56
|
openAlert({
|
|
63
|
-
type:
|
|
57
|
+
type: alertVariants.error,
|
|
64
58
|
caption: 'Oops, something went wrong.',
|
|
65
59
|
});
|
|
66
60
|
setCollections([]);
|
|
67
61
|
setNextPageToken(null);
|
|
68
62
|
},
|
|
69
63
|
});
|
|
70
|
-
const [fetchCollectionsLikes, { loading: collectionsLikesLoading }] =
|
|
71
|
-
context: { uri:
|
|
64
|
+
const [fetchCollectionsLikes, { loading: collectionsLikesLoading }] = useLazyQuery(FetchDynamicCollectionsDataDocument, {
|
|
65
|
+
context: { uri: hosts.searchHost },
|
|
72
66
|
onCompleted: ({ fetchDynamicCollectionsData }) => {
|
|
73
67
|
setCollectionsLikes(fetchDynamicCollectionsData);
|
|
74
68
|
setLoading(false);
|
|
@@ -76,16 +70,16 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
76
70
|
fetchPolicy: 'no-cache',
|
|
77
71
|
onError: () => {
|
|
78
72
|
openAlert({
|
|
79
|
-
type:
|
|
73
|
+
type: alertVariants.error,
|
|
80
74
|
caption: 'Oops, something went wrong when fetch collections likes.',
|
|
81
75
|
});
|
|
82
76
|
setCollectionsLikes([]);
|
|
83
77
|
setLoading(false);
|
|
84
78
|
},
|
|
85
79
|
});
|
|
86
|
-
|
|
80
|
+
useEffect(() => {
|
|
87
81
|
if (collections.length > 0) {
|
|
88
|
-
const itemsIdsArray =
|
|
82
|
+
const itemsIdsArray = extractItemIds(collections);
|
|
89
83
|
if (itemsIdsArray.length > 0) {
|
|
90
84
|
if (collections[0].getItemType() === 'collection') {
|
|
91
85
|
fetchCollectionsLikes({
|
|
@@ -101,7 +95,7 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
101
95
|
}
|
|
102
96
|
}
|
|
103
97
|
}, [collections, fetchCollectionsLikes]);
|
|
104
|
-
|
|
98
|
+
useEffect(() => {
|
|
105
99
|
setLoading(true);
|
|
106
100
|
setCollectionsLikes([]);
|
|
107
101
|
setCollections([]);
|
|
@@ -133,7 +127,7 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
133
127
|
},
|
|
134
128
|
});
|
|
135
129
|
const { collections: nextCollections, ...nextPage } = data.findCollections;
|
|
136
|
-
const nextList = nextCollections.map((collectionAsset) => new
|
|
130
|
+
const nextList = nextCollections.map((collectionAsset) => new CollectionCreationEntity({
|
|
137
131
|
...collectionAsset,
|
|
138
132
|
name: collectionAsset && collectionAsset.collectionTitle,
|
|
139
133
|
}, 'collection'));
|
|
@@ -146,5 +140,4 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
146
140
|
}
|
|
147
141
|
}
|
|
148
142
|
};
|
|
149
|
-
|
|
150
|
-
exports.default = { /*prefetchFindCollections,*/ useFindCollectionsAndLikes: /*prefetchFindCollections,*/ exports.useFindCollectionsAndLikes };
|
|
143
|
+
export default { /*prefetchFindCollections,*/ useFindCollectionsAndLikes };
|