@ludo.ninja/components 2.2.35 → 2.2.37
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/server-galleries/queries/useFetchGallery/index.d.ts +5 -5
- package/build/api/server-galleries/queries/useFetchGallery/index.js +5 -8
- package/build/api/server-galleries/queries/useFetchMyFavorites/index.d.ts +3 -3
- package/build/api/server-galleries/queries/useFetchMyFavorites/index.js +5 -11
- package/build/api/server-galleries/queries/useFetchMyGalleries/index.d.ts +3 -3
- package/build/api/server-galleries/queries/useFetchMyGalleries/index.js +5 -11
- package/build/api/server-galleries/queries/useFetchUserFavorites/index.d.ts +4 -4
- package/build/api/server-galleries/queries/useFetchUserFavorites/index.js +6 -9
- package/build/api/server-search/queries/useFetchFindAllTopEntitiesByName/index.d.ts +6 -6
- package/build/api/server-search/queries/useFetchFindAllTopEntitiesByName/index.js +4 -7
- package/build/components/assetPage/assetLikes/index.js +7 -7
- package/build/components/search/searchSuggestions/index.d.ts +2 -2
- package/build/components/search/searchSuggestions/index.js +4 -46
- package/build/dto/AssetEntity/index.d.ts +3 -3
- package/build/dto/AssetEntity/index.js +16 -33
- package/build/dto/AssetSearchEntity/index.d.ts +2 -2
- package/build/dto/AssetSearchEntity/index.js +12 -29
- package/build/dto/Collection/CollectionCreationEntity/index.d.ts +3 -3
- package/build/dto/Collection/CollectionCreationEntity/index.js +13 -13
- package/build/dto/Collection/CollectionCreationEntity/interface.d.ts +2 -2
- package/build/dto/Collection/CollectionEntity/index.d.ts +2 -2
- package/build/dto/Collection/CollectionEntity/index.js +1 -1
- package/build/dto/CreationEntity/index.d.ts +3 -3
- package/build/dto/CreationEntity/index.js +9 -9
- package/build/dto/GalleryEntityV2/index.d.ts +4 -4
- package/build/dto/GalleryEntityV2/index.js +6 -8
- package/build/dto/common/ItemType/data.d.ts +1 -1
- package/build/dto/common/ItemType/data.js +25 -25
- package/build/entities/asset/AssetMediasViews.js +6 -6
- package/build/entities/asset/builder.js +2 -2
- package/build/entities/asset/{assetMediasOpengraph.d.ts → getAssetMediasOpengraph.d.ts} +1 -1
- package/build/entities/asset/{assetMediasOpengraph.js → getAssetMediasOpengraph.js} +7 -7
- package/build/entities/asset/getAssetMiniatureUrl.d.ts +4 -0
- package/build/entities/asset/getAssetMiniatureUrl.js +37 -0
- package/build/entities/asset/types.d.ts +1 -1
- package/build/entities/collection/builder.d.ts +3 -0
- package/build/entities/collection/builder.js +31 -0
- package/build/entities/collection/types.d.ts +17 -0
- package/build/entities/collection/types.js +2 -0
- package/build/entities/creation/CreationMediaView.d.ts +4 -0
- package/build/entities/creation/CreationMediaView.js +46 -0
- package/build/entities/creation/builder.d.ts +3 -0
- package/build/entities/creation/builder.js +63 -0
- package/build/entities/creation/collectionCreationBuilder.d.ts +3 -0
- package/build/entities/creation/collectionCreationBuilder.js +25 -0
- package/build/entities/creation/types.d.ts +23 -0
- package/build/entities/creation/types.js +2 -0
- package/build/entities/gallery/builder.d.ts +3 -0
- package/build/entities/gallery/builder.js +35 -0
- package/build/entities/gallery/types.d.ts +18 -0
- package/build/entities/gallery/types.js +2 -0
- package/build/entities/labelCreationType/data.d.ts +3 -0
- package/build/entities/labelCreationType/data.js +36 -0
- package/build/entities/labelCreationType/types.d.ts +45 -0
- package/build/entities/labelCreationType/types.js +42 -0
- package/build/entities/media/builder.d.ts +4 -0
- package/build/entities/media/builder.js +11 -1
- package/build/entities/media/types.d.ts +1 -1
- package/build/entities/media/urls.d.ts +31 -0
- package/build/entities/media/urls.js +125 -0
- package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.d.ts +4 -4
- package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.js +17 -19
- package/build/hooks/favorites/useGetUserFevoritesCreations/index.d.ts +5 -5
- package/build/hooks/favorites/useGetUserFevoritesCreations/index.js +23 -33
- package/build/hooks/galleries/useGetUserGalleriesCreations/index.d.ts +5 -5
- package/build/hooks/galleries/useGetUserGalleriesCreations/index.js +23 -33
- package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.d.ts +1 -1
- package/build/hooks/likes/index.d.ts +1 -1
- package/build/hooks/likes/index.js +12 -12
- package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.d.ts +4 -4
- package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.js +35 -40
- package/build/modules/gallery/store.d.ts +3 -3
- package/build/modules/gallery/store.js +7 -11
- package/build/modules/gallery/ui/EditGallery.d.ts +2 -2
- package/build/modules/gallery/ui/EditGallery.js +11 -11
- package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.d.ts +3 -3
- package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.js +1 -1
- package/build/modules/gallery/ui/chooseGalleryItems/index.d.ts +1 -1
- package/build/modules/gallery/ui/chooseGalleryItems/index.js +19 -20
- package/build/modules/opportunity/OpportunityCard.js +25 -27
- package/build/system/Cards/CardContent/CardCategory/CardCategory.test.d.ts +1 -1
- package/build/system/Cards/CardContent/CardCategory/CardCategory.test.js +9 -9
- package/build/system/Cards/CardContent/CardCategory/index.d.ts +1 -1
- package/build/system/Cards/CardContent/CardCategory/index.js +3 -3
- package/build/system/Cards/CreationCard/CardHead.js +16 -21
- package/build/system/Cards/CreationCard/index.d.ts +2 -2
- package/build/system/Cards/CreationCard/index.js +5 -5
- package/build/system/Cards/MultiMediaCard/index.d.ts +2 -2
- package/build/system/Cards/MultiMediaCard/index.js +3 -3
- package/package.json +1 -1
|
@@ -4,17 +4,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useGetFavoriteGallaryCreations = void 0;
|
|
7
|
-
const
|
|
7
|
+
const useGetUserFevoritesCreations_1 = require("../useGetUserFevoritesCreations");
|
|
8
|
+
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
9
|
+
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
10
|
+
const builder_1 = require("../../../entities/gallery/builder");
|
|
11
|
+
const ui_1 = require("../../../store/ui");
|
|
8
12
|
const client_1 = require("@apollo/client");
|
|
9
13
|
const api_1 = require("@ludo.ninja/api");
|
|
10
14
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
|
|
11
15
|
const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
12
16
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
13
|
-
const
|
|
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");
|
|
17
|
+
const react_1 = require("react");
|
|
18
18
|
const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
19
19
|
const [gallery, setGallery] = (0, react_1.useState)([]);
|
|
20
20
|
const [assets, setAssets] = (0, react_1.useState)(null);
|
|
@@ -30,9 +30,9 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
30
30
|
uri: api_1.hosts.galleriesHost,
|
|
31
31
|
},
|
|
32
32
|
notifyOnNetworkStatusChange: true,
|
|
33
|
-
fetchPolicy:
|
|
33
|
+
fetchPolicy: "no-cache",
|
|
34
34
|
onCompleted: ({ fetchGalleryV2 }) => {
|
|
35
|
-
setGallery([
|
|
35
|
+
setGallery([(0, builder_1.buildGallery)(fetchGalleryV2)]);
|
|
36
36
|
setAllResults(fetchGalleryV2.items);
|
|
37
37
|
},
|
|
38
38
|
onError: () => {
|
|
@@ -44,13 +44,13 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
44
44
|
});
|
|
45
45
|
const [fetchAssets, { loading: assetsLoading, error: assetsError }] = (0, client_1.useLazyQuery)(schema_2.FetchAssetsDocument, {
|
|
46
46
|
context: { uri: api_1.hosts.searchHost },
|
|
47
|
-
fetchPolicy:
|
|
47
|
+
fetchPolicy: "no-cache",
|
|
48
48
|
onCompleted: ({ fetchAssets: data }) => {
|
|
49
49
|
setAssets((prevAssets) => [
|
|
50
50
|
...(prevAssets || []),
|
|
51
51
|
...data.map((asset) => new CreationEntity_1.default({
|
|
52
52
|
...asset,
|
|
53
|
-
itemType:
|
|
53
|
+
itemType: "asset",
|
|
54
54
|
itemId: asset.assetId,
|
|
55
55
|
})),
|
|
56
56
|
]);
|
|
@@ -58,25 +58,25 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
58
58
|
onError: () => {
|
|
59
59
|
openAlert({
|
|
60
60
|
type: type_1.alertVariants.error,
|
|
61
|
-
caption:
|
|
61
|
+
caption: "Oops, something went wrong.",
|
|
62
62
|
});
|
|
63
63
|
setAssets([]);
|
|
64
64
|
setFetchError(true);
|
|
65
65
|
},
|
|
66
66
|
});
|
|
67
|
-
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }
|
|
67
|
+
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
|
|
68
68
|
context: { uri: api_1.hosts.searchHost },
|
|
69
|
-
fetchPolicy:
|
|
69
|
+
fetchPolicy: "no-cache",
|
|
70
70
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
71
71
|
setCollections((prevCollections) => [
|
|
72
72
|
...(prevCollections || []),
|
|
73
|
-
...data.map((collection) => new CollectionCreationEntity_1.default(collection,
|
|
73
|
+
...data.map((collection) => new CollectionCreationEntity_1.default(collection, "collection")),
|
|
74
74
|
]);
|
|
75
75
|
},
|
|
76
76
|
onError: () => {
|
|
77
77
|
openAlert({
|
|
78
78
|
type: type_1.alertVariants.error,
|
|
79
|
-
caption:
|
|
79
|
+
caption: "Oops, something went wrong.",
|
|
80
80
|
});
|
|
81
81
|
setCollections([]);
|
|
82
82
|
setFetchError(true);
|
|
@@ -85,9 +85,7 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
85
85
|
(0, react_1.useEffect)(() => {
|
|
86
86
|
if (gallery && gallery.length > 0) {
|
|
87
87
|
const { assetArray, collectionsArray } = (0, useGetUserFevoritesCreations_1.getMediaForGallery)(gallery, false, currentPage, itemsCount);
|
|
88
|
-
const assetPromise = assetArray.length > 0
|
|
89
|
-
? fetchAssets({ variables: { assetIds: assetArray } })
|
|
90
|
-
: Promise.resolve();
|
|
88
|
+
const assetPromise = assetArray.length > 0 ? fetchAssets({ variables: { assetIds: assetArray } }) : Promise.resolve();
|
|
91
89
|
const collectionsPromise = collectionsArray.length > 0
|
|
92
90
|
? fetchCollections({ variables: { collectionIds: collectionsArray } })
|
|
93
91
|
: Promise.resolve();
|
|
@@ -101,7 +99,7 @@ const useGetFavoriteGallaryCreations = ({ galleryId, itemsCount, }) => {
|
|
|
101
99
|
});
|
|
102
100
|
}
|
|
103
101
|
}, [gallery, fetchAssets, fetchCollections, currentPage]);
|
|
104
|
-
async function refetchQueryGalleryCreation({ galleryId
|
|
102
|
+
async function refetchQueryGalleryCreation({ galleryId }) {
|
|
105
103
|
await refetch({ galleryId });
|
|
106
104
|
}
|
|
107
105
|
function loadMore() {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IQueryFetchUserFavoritesV2Args } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
|
|
2
1
|
import CollectionCreationEntity from '../../../dto/Collection/CollectionCreationEntity';
|
|
3
2
|
import CreationEntity from '../../../dto/CreationEntity';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { TGallery } from '../../../entities/gallery/types';
|
|
4
|
+
import { IQueryFetchUserFavoritesV2Args } from "@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema";
|
|
5
|
+
declare const useGetUserFevoritesCreations: ({ userId, pageSize, pageToken }: IQueryFetchUserFavoritesV2Args) => {
|
|
6
|
+
favorites: TGallery[];
|
|
7
7
|
assets: CreationEntity[] | null;
|
|
8
8
|
collections: CollectionCreationEntity[] | null;
|
|
9
9
|
loading: boolean;
|
|
@@ -18,7 +18,7 @@ declare const useGetUserFevoritesCreations: ({ userId, pageSize, pageToken, }: I
|
|
|
18
18
|
isNextLoading: boolean;
|
|
19
19
|
};
|
|
20
20
|
export { useGetUserFevoritesCreations };
|
|
21
|
-
export declare function getMediaForGallery(favorites:
|
|
21
|
+
export declare function getMediaForGallery(favorites: TGallery[], takeFirstFour: boolean, pageNumber?: number, totalLength?: number | null): {
|
|
22
22
|
assetArray: unknown[];
|
|
23
23
|
collectionsArray: unknown[];
|
|
24
24
|
};
|
|
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useGetUserFevoritesCreations = void 0;
|
|
7
7
|
exports.getMediaForGallery = getMediaForGallery;
|
|
8
|
-
const
|
|
8
|
+
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
9
|
+
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
10
|
+
const builder_1 = require("../../../entities/gallery/builder");
|
|
11
|
+
const ui_1 = require("../../../store/ui");
|
|
9
12
|
const client_1 = require("@apollo/client");
|
|
10
13
|
const api_1 = require("@ludo.ninja/api");
|
|
11
14
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
|
|
12
15
|
const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
13
16
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
14
|
-
const
|
|
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"));
|
|
17
|
+
const react_1 = require("react");
|
|
18
18
|
const maxUserFavoritesLength = 1000;
|
|
19
|
-
const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken
|
|
19
|
+
const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken }) => {
|
|
20
20
|
const [assets, setAsset] = (0, react_1.useState)(null);
|
|
21
21
|
const [collections, setCollections] = (0, react_1.useState)(null);
|
|
22
22
|
const [favorites, setFavorites] = (0, react_1.useState)([]);
|
|
@@ -29,17 +29,17 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
29
29
|
const { loading: favoritesLoading, error: favoritesError, refetch, fetchMore, } = (0, client_1.useQuery)(schema_1.FetchUserFavoritesV2Document, {
|
|
30
30
|
context: { uri: api_1.hosts.galleriesHost }, //todo : update variables to object page
|
|
31
31
|
variables: { pageSize, userId, pageToken },
|
|
32
|
-
fetchPolicy:
|
|
33
|
-
onCompleted: ({ fetchUserFavoritesV2: { galleries, nextPageToken: token }
|
|
32
|
+
fetchPolicy: "no-cache",
|
|
33
|
+
onCompleted: ({ fetchUserFavoritesV2: { galleries, nextPageToken: token } }) => {
|
|
34
34
|
// nextPageToken.current = nextPage.nextPage?.token || null;
|
|
35
35
|
nextPageToken.current = token || null;
|
|
36
|
-
setFavorites(galleries.map((gallery) =>
|
|
36
|
+
setFavorites(galleries.map((gallery) => (0, builder_1.buildGallery)(gallery)));
|
|
37
37
|
setLoading(false);
|
|
38
38
|
},
|
|
39
39
|
onError: () => {
|
|
40
40
|
openAlert({
|
|
41
41
|
type: type_1.alertVariants.error,
|
|
42
|
-
caption:
|
|
42
|
+
caption: "Oops, something went wrong while fetching favorites.",
|
|
43
43
|
});
|
|
44
44
|
setFavorites([]);
|
|
45
45
|
setLoading(false);
|
|
@@ -47,11 +47,11 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
47
47
|
});
|
|
48
48
|
const [fetchAssets, { loading: assetsLoading, error: assetsError }] = (0, client_1.useLazyQuery)(schema_2.FetchAssetsDocument, {
|
|
49
49
|
context: { uri: api_1.hosts.searchHost },
|
|
50
|
-
fetchPolicy:
|
|
50
|
+
fetchPolicy: "no-cache",
|
|
51
51
|
onCompleted: ({ fetchAssets: data }) => {
|
|
52
52
|
setAsset(data.map((asset) => new CreationEntity_1.default({
|
|
53
53
|
...asset,
|
|
54
|
-
itemType:
|
|
54
|
+
itemType: "asset",
|
|
55
55
|
itemId: asset.assetId,
|
|
56
56
|
})));
|
|
57
57
|
setLoading(false);
|
|
@@ -59,15 +59,15 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
59
59
|
onError: () => {
|
|
60
60
|
openAlert({
|
|
61
61
|
type: type_1.alertVariants.error,
|
|
62
|
-
caption:
|
|
62
|
+
caption: "Oops, something went wrong.",
|
|
63
63
|
});
|
|
64
64
|
setAsset(null);
|
|
65
65
|
setLoading(false);
|
|
66
66
|
},
|
|
67
67
|
});
|
|
68
|
-
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }
|
|
68
|
+
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
|
|
69
69
|
context: { uri: api_1.hosts.searchHost },
|
|
70
|
-
fetchPolicy:
|
|
70
|
+
fetchPolicy: "no-cache",
|
|
71
71
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
72
72
|
setCollections(data.map((collection) => new CollectionCreationEntity_1.default(collection)));
|
|
73
73
|
setLoading(false);
|
|
@@ -75,7 +75,7 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
75
75
|
onError: () => {
|
|
76
76
|
openAlert({
|
|
77
77
|
type: type_1.alertVariants.error,
|
|
78
|
-
caption:
|
|
78
|
+
caption: "Oops, something went wrong.",
|
|
79
79
|
});
|
|
80
80
|
setCollections(null);
|
|
81
81
|
setLoading(false);
|
|
@@ -96,9 +96,7 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
96
96
|
await refetch();
|
|
97
97
|
}
|
|
98
98
|
async function loadMoreFavoritesList() {
|
|
99
|
-
if (!nextPageToken.current ||
|
|
100
|
-
!isHaveNextPage ||
|
|
101
|
-
favorites.length >= maxUserFavoritesLength)
|
|
99
|
+
if (!nextPageToken.current || !isHaveNextPage || favorites.length >= maxUserFavoritesLength)
|
|
102
100
|
return;
|
|
103
101
|
setIsNextLoading(true);
|
|
104
102
|
try {
|
|
@@ -109,7 +107,7 @@ const useGetUserFevoritesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
109
107
|
return prev;
|
|
110
108
|
const { nextPageToken: token, favorites: nextFavorites } = fetchMoreResult.fetchMyFavoritesV2;
|
|
111
109
|
nextPageToken.current = token || null;
|
|
112
|
-
if (prev !== null && prev.hasOwnProperty(
|
|
110
|
+
if (prev !== null && prev.hasOwnProperty("fetchMyFavoritesV2")) {
|
|
113
111
|
const { favorites: prevFavorites } = prev.fetchMyFavoritesV2;
|
|
114
112
|
return {
|
|
115
113
|
fetchMyFavorites: {
|
|
@@ -160,26 +158,18 @@ function getMediaForGallery(favorites, takeFirstFour, pageNumber = 1, totalLengt
|
|
|
160
158
|
const assetArray = [];
|
|
161
159
|
const collectionsArray = [];
|
|
162
160
|
favorites.forEach((fav) => {
|
|
163
|
-
const creationIds = takeFirstFour
|
|
164
|
-
? fav.getGalleryCreationIds().slice(0, 4)
|
|
165
|
-
: fav.getGalleryCreationIds();
|
|
161
|
+
const creationIds = takeFirstFour ? fav.creationIds.slice(0, 4) : fav.creationIds;
|
|
166
162
|
if (!creationIds || creationIds.length === 0)
|
|
167
163
|
return;
|
|
168
164
|
const startIndex = (pageNumber - 1) * itemsPerPage;
|
|
169
165
|
const endIndex = totalLength ? totalLength : startIndex + itemsPerPage;
|
|
170
166
|
for (let i = startIndex; i < endIndex && i < creationIds.length; i++) {
|
|
171
|
-
if (creationIds[i].split(
|
|
172
|
-
const assetId = creationIds[i]
|
|
173
|
-
.split('.')
|
|
174
|
-
.splice(1, creationIds[i].length)
|
|
175
|
-
.join('.');
|
|
167
|
+
if (creationIds[i].split(".")[0] === "asset") {
|
|
168
|
+
const assetId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
|
|
176
169
|
assetArray.push(assetId);
|
|
177
170
|
}
|
|
178
|
-
else if (creationIds[i].split(
|
|
179
|
-
const collectionId = creationIds[i]
|
|
180
|
-
.split('.')
|
|
181
|
-
.splice(1, creationIds[i].length)
|
|
182
|
-
.join('.');
|
|
171
|
+
else if (creationIds[i].split(".")[0] === "collection") {
|
|
172
|
+
const collectionId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
|
|
183
173
|
collectionsArray.push(collectionId);
|
|
184
174
|
}
|
|
185
175
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IQueryFetchUserGalleriesV2Args } from '@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema';
|
|
2
1
|
import CollectionCreationEntity from '../../../dto/Collection/CollectionCreationEntity';
|
|
3
2
|
import CreationEntity from '../../../dto/CreationEntity';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { TGallery } from '../../../entities/gallery/types';
|
|
4
|
+
import { IQueryFetchUserGalleriesV2Args } from "@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema";
|
|
5
|
+
declare const useGetUserGalleriesCreations: ({ userId, pageSize, pageToken }: IQueryFetchUserGalleriesV2Args) => {
|
|
6
|
+
galleries: TGallery[];
|
|
7
7
|
assets: CreationEntity[] | null;
|
|
8
8
|
collections: CollectionCreationEntity[] | null;
|
|
9
9
|
loading: boolean;
|
|
@@ -18,7 +18,7 @@ declare const useGetUserGalleriesCreations: ({ userId, pageSize, pageToken, }: I
|
|
|
18
18
|
isNextLoading: boolean;
|
|
19
19
|
};
|
|
20
20
|
export { useGetUserGalleriesCreations };
|
|
21
|
-
export declare function getMediaForGallery(favorites:
|
|
21
|
+
export declare function getMediaForGallery(favorites: TGallery[], takeFirstFour: boolean): {
|
|
22
22
|
assetArray: unknown[];
|
|
23
23
|
collectionsArray: unknown[];
|
|
24
24
|
};
|
|
@@ -5,18 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useGetUserGalleriesCreations = void 0;
|
|
7
7
|
exports.getMediaForGallery = getMediaForGallery;
|
|
8
|
-
const
|
|
8
|
+
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
9
|
+
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
10
|
+
const builder_1 = require("../../../entities/gallery/builder");
|
|
11
|
+
const ui_1 = require("../../../store/ui");
|
|
9
12
|
const client_1 = require("@apollo/client");
|
|
10
13
|
const api_1 = require("@ludo.ninja/api");
|
|
11
14
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
|
|
12
15
|
const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
13
16
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
14
|
-
const
|
|
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"));
|
|
17
|
+
const react_1 = require("react");
|
|
18
18
|
const maxUserFavoritesLength = 1000;
|
|
19
|
-
const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken
|
|
19
|
+
const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken }) => {
|
|
20
20
|
const [assets, setAsset] = (0, react_1.useState)(null);
|
|
21
21
|
const [collections, setCollections] = (0, react_1.useState)(null);
|
|
22
22
|
const [galleries, setGalleries] = (0, react_1.useState)([]);
|
|
@@ -29,17 +29,17 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
29
29
|
const { loading: favoritesLoading, error: galleriesError, refetch, fetchMore, } = (0, client_1.useQuery)(schema_1.FetchUserGalleriesV2Document, {
|
|
30
30
|
context: { uri: api_1.hosts.galleriesHost },
|
|
31
31
|
variables: { pageSize, userId, pageToken },
|
|
32
|
-
fetchPolicy:
|
|
33
|
-
onCompleted: ({ fetchUserGalleriesV2: { galleries, nextPageToken: token }
|
|
32
|
+
fetchPolicy: "no-cache",
|
|
33
|
+
onCompleted: ({ fetchUserGalleriesV2: { galleries, nextPageToken: token } }) => {
|
|
34
34
|
// nextPageToken.current = nextPage.nextPage?.token || null;
|
|
35
35
|
nextPageToken.current = token || null;
|
|
36
|
-
setGalleries(galleries.map((gallery) =>
|
|
36
|
+
setGalleries(galleries.map((gallery) => (0, builder_1.buildGallery)(gallery)));
|
|
37
37
|
setLoading(false);
|
|
38
38
|
},
|
|
39
39
|
onError: () => {
|
|
40
40
|
openAlert({
|
|
41
41
|
type: type_1.alertVariants.error,
|
|
42
|
-
caption:
|
|
42
|
+
caption: "Oops, something went wrong while fetching galleries.",
|
|
43
43
|
});
|
|
44
44
|
setGalleries([]);
|
|
45
45
|
setLoading(false);
|
|
@@ -47,11 +47,11 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
47
47
|
});
|
|
48
48
|
const [fetchAssets, { loading: assetsLoading, error: assetsError }] = (0, client_1.useLazyQuery)(schema_2.FetchAssetsDocument, {
|
|
49
49
|
context: { uri: api_1.hosts.searchHost },
|
|
50
|
-
fetchPolicy:
|
|
50
|
+
fetchPolicy: "no-cache",
|
|
51
51
|
onCompleted: ({ fetchAssets: data }) => {
|
|
52
52
|
setAsset(data.map((asset) => new CreationEntity_1.default({
|
|
53
53
|
...asset,
|
|
54
|
-
itemType:
|
|
54
|
+
itemType: "asset",
|
|
55
55
|
itemId: asset.assetId,
|
|
56
56
|
})));
|
|
57
57
|
setLoading(false);
|
|
@@ -59,15 +59,15 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
59
59
|
onError: () => {
|
|
60
60
|
openAlert({
|
|
61
61
|
type: type_1.alertVariants.error,
|
|
62
|
-
caption:
|
|
62
|
+
caption: "Oops, something went wrong.",
|
|
63
63
|
});
|
|
64
64
|
setAsset(null);
|
|
65
65
|
setLoading(false);
|
|
66
66
|
},
|
|
67
67
|
});
|
|
68
|
-
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }
|
|
68
|
+
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
|
|
69
69
|
context: { uri: api_1.hosts.searchHost },
|
|
70
|
-
fetchPolicy:
|
|
70
|
+
fetchPolicy: "no-cache",
|
|
71
71
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
72
72
|
setCollections(data.map((collection) => new CollectionCreationEntity_1.default(collection)));
|
|
73
73
|
setLoading(false);
|
|
@@ -75,7 +75,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
75
75
|
onError: () => {
|
|
76
76
|
openAlert({
|
|
77
77
|
type: type_1.alertVariants.error,
|
|
78
|
-
caption:
|
|
78
|
+
caption: "Oops, something went wrong.",
|
|
79
79
|
});
|
|
80
80
|
setCollections(null);
|
|
81
81
|
setLoading(false);
|
|
@@ -96,9 +96,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
96
96
|
await refetch();
|
|
97
97
|
}
|
|
98
98
|
async function loadMoreGalleriesList() {
|
|
99
|
-
if (!nextPageToken.current ||
|
|
100
|
-
!isHaveNextPage ||
|
|
101
|
-
galleries.length >= maxUserFavoritesLength)
|
|
99
|
+
if (!nextPageToken.current || !isHaveNextPage || galleries.length >= maxUserFavoritesLength)
|
|
102
100
|
return;
|
|
103
101
|
setIsNextLoading(true);
|
|
104
102
|
await fetchMore({
|
|
@@ -108,7 +106,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
108
106
|
return prev;
|
|
109
107
|
const { nextPageToken: token, galleries: nextGalleries } = fetchMoreResult.fetchMyFavoritesV2;
|
|
110
108
|
nextPageToken.current = token || null;
|
|
111
|
-
if (prev !== null && prev.hasOwnProperty(
|
|
109
|
+
if (prev !== null && prev.hasOwnProperty("fetchMyGalleriesV2")) {
|
|
112
110
|
const { galleries: prevGalleries } = prev.fetchMyGalleriesV2;
|
|
113
111
|
return {
|
|
114
112
|
fetchMyGalleriesV2: {
|
|
@@ -151,24 +149,16 @@ function getMediaForGallery(favorites, takeFirstFour) {
|
|
|
151
149
|
const assetArray = [];
|
|
152
150
|
const collectionsArray = [];
|
|
153
151
|
favorites.forEach((fav) => {
|
|
154
|
-
const creationIds = takeFirstFour
|
|
155
|
-
? fav.getGalleryCreationIds().slice(0, 4)
|
|
156
|
-
: fav.getGalleryCreationIds();
|
|
152
|
+
const creationIds = takeFirstFour ? fav.creationIds.slice(0, 4) : fav.creationIds;
|
|
157
153
|
if (!creationIds || creationIds.length === 0)
|
|
158
154
|
return;
|
|
159
155
|
for (let i = 0; i < creationIds.length; i++) {
|
|
160
|
-
if (creationIds[i].split(
|
|
161
|
-
const assetId = creationIds[i]
|
|
162
|
-
.split('.')
|
|
163
|
-
.splice(1, creationIds[i].length)
|
|
164
|
-
.join('.');
|
|
156
|
+
if (creationIds[i].split(".")[0] === "asset") {
|
|
157
|
+
const assetId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
|
|
165
158
|
assetArray.push(assetId);
|
|
166
159
|
}
|
|
167
|
-
else if (creationIds[i].split(
|
|
168
|
-
const collectionId = creationIds[i]
|
|
169
|
-
.split('.')
|
|
170
|
-
.splice(1, creationIds[i].length)
|
|
171
|
-
.join('.');
|
|
160
|
+
else if (creationIds[i].split(".")[0] === "collection") {
|
|
161
|
+
const collectionId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
|
|
172
162
|
collectionsArray.push(collectionId);
|
|
173
163
|
}
|
|
174
164
|
}
|
|
@@ -5,7 +5,7 @@ declare const useGetMixedLikesFavoriteList: ({ galleryId, itemsCount, }: {
|
|
|
5
5
|
galleryId: string;
|
|
6
6
|
itemsCount: number | null;
|
|
7
7
|
}) => {
|
|
8
|
-
gallery: import("../../../
|
|
8
|
+
gallery: import("../../../entities/gallery/types").TGallery[] | null;
|
|
9
9
|
creationsList: [] | (CreationEntity | CollectionCreationEntity)[];
|
|
10
10
|
likes: (schema.IDynamicAssetData | schema.IDynamicCollectionData)[];
|
|
11
11
|
allResults: number | null;
|
|
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
8
|
-
const ui_1 = require("../../store/ui");
|
|
9
6
|
const useDislikeAsset_1 = __importDefault(require("../../api/server-assets/mutations/useDislikeAsset"));
|
|
10
7
|
const useLikeAsset_1 = __importDefault(require("../../api/server-assets/mutations/useLikeAsset"));
|
|
11
8
|
const useDislikeCollection_1 = __importDefault(require("../../api/server-collection/mutations/useDislikeCollection"));
|
|
12
9
|
const useLikeCollection_1 = __importDefault(require("../../api/server-collection/mutations/useLikeCollection"));
|
|
13
10
|
const useRemoveAssetFromGallery_1 = require("../../api/server-galleries/mutations/useRemoveAssetFromGallery");
|
|
14
11
|
const useRemoveCollectionFromGallery_1 = require("../../api/server-galleries/mutations/useRemoveCollectionFromGallery");
|
|
15
|
-
const
|
|
12
|
+
const types_1 = require("../../entities/labelCreationType/types");
|
|
13
|
+
const ui_1 = require("../../store/ui");
|
|
14
|
+
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
15
|
+
const react_1 = require("react");
|
|
16
16
|
// Component
|
|
17
17
|
const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike, isLoadingLikes, }) => {
|
|
18
18
|
const [likes, setLikes] = (0, react_1.useState)({
|
|
@@ -44,8 +44,8 @@ const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike
|
|
|
44
44
|
errorRemoveCollection) {
|
|
45
45
|
openAlert({
|
|
46
46
|
type: type_1.alertVariants.error,
|
|
47
|
-
caption:
|
|
48
|
-
text:
|
|
47
|
+
caption: "Oops, something went wrong.",
|
|
48
|
+
text: "Please try another NFT",
|
|
49
49
|
});
|
|
50
50
|
setLikes({
|
|
51
51
|
likesCount: defaultLikesCount,
|
|
@@ -63,10 +63,10 @@ const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike
|
|
|
63
63
|
]);
|
|
64
64
|
const addLike = async (id) => {
|
|
65
65
|
setIsLoading(true);
|
|
66
|
-
if (itemType ===
|
|
66
|
+
if (itemType === types_1.LabelKeys.asset) {
|
|
67
67
|
await likeAsset({ assetId: id });
|
|
68
68
|
}
|
|
69
|
-
else if (itemType ===
|
|
69
|
+
else if (itemType === types_1.LabelKeys.collection) {
|
|
70
70
|
await likeCollection({ collectionId: id });
|
|
71
71
|
}
|
|
72
72
|
if (!errorLikeAsset || !errorLikeCollection) {
|
|
@@ -79,21 +79,21 @@ const useLikes = ({ defaultLikesCount, defaultIsLiked, itemType, removeOnDislike
|
|
|
79
79
|
};
|
|
80
80
|
const deleteLike = async (id) => {
|
|
81
81
|
setIsLoading(true);
|
|
82
|
-
if (itemType ===
|
|
82
|
+
if (itemType === types_1.LabelKeys.asset) {
|
|
83
83
|
await dislikeAsset({ assetId: id });
|
|
84
84
|
if (removeOnDislike && removeOnDislike.gallery) {
|
|
85
85
|
await removeAssetFromGallery({
|
|
86
|
-
galleryId: removeOnDislike.gallery.
|
|
86
|
+
galleryId: removeOnDislike.gallery.galleryId,
|
|
87
87
|
assetId: id,
|
|
88
88
|
});
|
|
89
89
|
removeOnDislike?.removeFn(itemType);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
else if (itemType ===
|
|
92
|
+
else if (itemType === types_1.LabelKeys.collection) {
|
|
93
93
|
await dislikeCollection({ collectionId: id });
|
|
94
94
|
if (removeOnDislike && removeOnDislike.gallery) {
|
|
95
95
|
await removeCollectionFromGallery({
|
|
96
|
-
galleryId: removeOnDislike.gallery.
|
|
96
|
+
galleryId: removeOnDislike.gallery.galleryId,
|
|
97
97
|
collectionId: id,
|
|
98
98
|
});
|
|
99
99
|
removeOnDislike?.removeFn(itemType);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { TCreationAndCollection } from '../../virtuoso/types';
|
|
3
|
-
import { TActiveTab } from '../../../system/Tabs/TabsNav/type';
|
|
1
|
+
import { TGallery } from '../../../entities/gallery/types';
|
|
4
2
|
import { TCurrentItemType } from '../../../hooks/likes/useGetLikesAsset';
|
|
5
3
|
import { TOpportunity } from '../../opportunity/type';
|
|
4
|
+
import { TCreationAndCollection } from '../../virtuoso/types';
|
|
5
|
+
import { TActiveTab } from '../../../system/Tabs/TabsNav/type';
|
|
6
6
|
export type TCreationWithOpportunity = TCreationAndCollection | TOpportunity;
|
|
7
7
|
export declare const useGetAssetsAndCollectionForFavorite: <TCreations>({ gallery, activeTab, fetchLikes, }: {
|
|
8
|
-
gallery:
|
|
8
|
+
gallery: TGallery;
|
|
9
9
|
activeTab: TActiveTab;
|
|
10
10
|
fetchLikes?: (itemsIdsArray: string[], currentItemType: TCurrentItemType) => Promise<void>;
|
|
11
11
|
}) => {
|