@ludo.ninja/components 2.2.36 → 2.2.38
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/useFetchAllCreations/index.d.ts +7 -7
- package/build/api/server-search/queries/useFetchAllCreations/index.js +7 -10
- package/build/api/server-search/queries/useFetchCollections/index.d.ts +6 -6
- package/build/api/server-search/queries/useFetchCollections/index.js +10 -12
- package/build/api/server-search/queries/useFetchDynamicCollectionData/index.d.ts +4 -4
- package/build/api/server-search/queries/useFetchDynamicCollectionData/index.js +8 -11
- package/build/api/server-search/queries/useFindCreations/index.d.ts +7 -7
- package/build/api/server-search/queries/useFindCreations/index.js +9 -12
- package/build/api/server-search/queries/useFindUserCreations/index.d.ts +3 -3
- package/build/api/server-search/queries/useFindUserCreations/index.js +7 -10
- package/build/api/server-search/queries/useFindUserLudoCreations/index.d.ts +3 -3
- package/build/api/server-search/queries/useFindUserLudoCreations/index.js +7 -10
- package/build/components/assetPage/assetLikes/index.js +7 -7
- package/build/components/gallery/add/addCreationToGallery/index.js +7 -7
- package/build/components/search/searchSuggestions/index.js +2 -2
- 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/creation/collectionCreationBuilder.d.ts +2 -2
- package/build/entities/creation/collectionCreationBuilder.js +4 -3
- package/build/entities/gallery/builder.js +1 -1
- package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.d.ts +6 -7
- package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.js +19 -23
- package/build/hooks/favorites/useGetUserFevoritesCreations/index.d.ts +8 -9
- package/build/hooks/favorites/useGetUserFevoritesCreations/index.js +25 -38
- package/build/hooks/galleries/useGetUserGalleriesCreations/index.d.ts +8 -9
- package/build/hooks/galleries/useGetUserGalleriesCreations/index.js +25 -38
- package/build/hooks/likes/dynamic/useFindCollectionsAndLikes.d.ts +6 -6
- package/build/hooks/likes/dynamic/useFindCollectionsAndLikes.js +15 -17
- package/build/hooks/likes/dynamic/useFindCreationsAndLikes.d.ts +4 -4
- package/build/hooks/likes/dynamic/useFindCreationsAndLikes.js +12 -15
- package/build/hooks/likes/dynamic/useGetCollectionInfoAndLikes.d.ts +4 -4
- package/build/hooks/likes/dynamic/useGetCollectionInfoAndLikes.js +11 -18
- package/build/hooks/likes/dynamic/useGetCreationsAndLikes.d.ts +4 -5
- package/build/hooks/likes/dynamic/useGetCreationsAndLikes.js +12 -17
- package/build/hooks/likes/dynamic/useGetCreationsAndLikesByType.d.ts +4 -4
- package/build/hooks/likes/dynamic/useGetCreationsAndLikesByType.js +16 -19
- package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.d.ts +5 -6
- package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.js +9 -10
- package/build/hooks/likes/dynamic/useGetTableLikes.d.ts +4 -5
- package/build/hooks/likes/dynamic/useGetTableLikes.js +14 -21
- 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 +5 -5
- package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.js +39 -47
- 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/gallery/ui/itemsPreview/index.d.ts +2 -3
- package/build/modules/gallery/ui/itemsPreview/index.js +9 -4
- package/build/modules/gallery/useToGalleryAsset.d.ts +5 -5
- package/build/modules/gallery/useToGalleryAsset.js +7 -7
- package/build/modules/opportunity/OpportunityCard.js +25 -27
- package/build/modules/virtuoso/types.d.ts +0 -3
- 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.d.ts +2 -3
- package/build/system/Cards/CreationCard/CardHead.js +16 -30
- package/build/system/Cards/CreationCard/index.d.ts +4 -4
- package/build/system/Cards/CreationCard/index.js +10 -9
- package/build/system/Cards/MultiMediaCard/index.d.ts +5 -6
- package/build/system/Cards/MultiMediaCard/index.js +8 -7
- package/build/utils/extractItemIds.d.ts +2 -2
- package/build/utils/extractItemIds.js +1 -7
- package/package.json +1 -1
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useGetCreationsAndLikesByType = void 0;
|
|
7
|
-
const
|
|
4
|
+
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
5
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
6
|
+
const ui_1 = require("../../../store/ui");
|
|
8
7
|
const client_1 = require("@apollo/client");
|
|
9
8
|
const api_1 = require("@ludo.ninja/api");
|
|
10
9
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
11
10
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
12
|
-
const
|
|
13
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
14
|
-
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
11
|
+
const react_1 = require("react");
|
|
15
12
|
const maxCreationLength = 1000;
|
|
16
|
-
const useGetCreationsAndLikesByType = ({ itemType, page
|
|
13
|
+
const useGetCreationsAndLikesByType = ({ itemType, page }) => {
|
|
17
14
|
const [allCreations, setAllCreations] = (0, react_1.useState)([]);
|
|
18
15
|
const [nextPageToken, setNextPageToken] = (0, react_1.useState)(null);
|
|
19
16
|
const [assetsLikes, setAssetsLikes] = (0, react_1.useState)([]);
|
|
@@ -29,16 +26,16 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
29
26
|
context: {
|
|
30
27
|
uri: api_1.hosts.searchHost,
|
|
31
28
|
},
|
|
32
|
-
fetchPolicy:
|
|
29
|
+
fetchPolicy: "no-cache",
|
|
33
30
|
onCompleted: ({ fetchCreationsByType: { creations, ...data } }) => {
|
|
34
|
-
setAllCreations(creations.map((creation) =>
|
|
31
|
+
setAllCreations(creations.map((creation) => (0, builder_1.buildCreation)(creation)));
|
|
35
32
|
setNextPageToken(data.nextPage?.token || null);
|
|
36
33
|
setLoading(false);
|
|
37
34
|
},
|
|
38
35
|
onError: () => {
|
|
39
36
|
openAlert({
|
|
40
37
|
type: type_1.alertVariants.error,
|
|
41
|
-
caption:
|
|
38
|
+
caption: "Oops, something went wrong.",
|
|
42
39
|
});
|
|
43
40
|
setAllCreations([]);
|
|
44
41
|
setNextPageToken(null);
|
|
@@ -49,7 +46,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
49
46
|
context: {
|
|
50
47
|
uri: api_1.hosts.searchHost,
|
|
51
48
|
},
|
|
52
|
-
fetchPolicy:
|
|
49
|
+
fetchPolicy: "no-cache",
|
|
53
50
|
onCompleted: ({ fetchDynamicAssetsData }) => {
|
|
54
51
|
setAssetsLikes(fetchDynamicAssetsData);
|
|
55
52
|
setLoading(false);
|
|
@@ -57,7 +54,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
57
54
|
onError: () => {
|
|
58
55
|
openAlert({
|
|
59
56
|
type: type_1.alertVariants.error,
|
|
60
|
-
caption:
|
|
57
|
+
caption: "Oops, something went wrong when fetch assets likes.",
|
|
61
58
|
});
|
|
62
59
|
setAssetsLikes([]);
|
|
63
60
|
setLoading(false);
|
|
@@ -69,11 +66,11 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
69
66
|
setCollectionsLikes(fetchDynamicCollectionsData);
|
|
70
67
|
setLoading(false);
|
|
71
68
|
},
|
|
72
|
-
fetchPolicy:
|
|
69
|
+
fetchPolicy: "no-cache",
|
|
73
70
|
onError: () => {
|
|
74
71
|
openAlert({
|
|
75
72
|
type: type_1.alertVariants.error,
|
|
76
|
-
caption:
|
|
73
|
+
caption: "Oops, something wrong with collections likes.",
|
|
77
74
|
});
|
|
78
75
|
setCollectionsLikes([]);
|
|
79
76
|
setLoading(false);
|
|
@@ -83,10 +80,10 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
83
80
|
if (allCreations.length > 0) {
|
|
84
81
|
const itemsIdsArray = (0, useGetCreationsAndLikes_1.extractItemIds)(allCreations);
|
|
85
82
|
if (itemsIdsArray.length > 0) {
|
|
86
|
-
if (currentItemType ===
|
|
83
|
+
if (currentItemType === "asset") {
|
|
87
84
|
fetchAssetsLikes({ variables: { assetIds: itemsIdsArray } });
|
|
88
85
|
}
|
|
89
|
-
else if (currentItemType ===
|
|
86
|
+
else if (currentItemType === "collection") {
|
|
90
87
|
fetchCollectionsLikes({
|
|
91
88
|
variables: {
|
|
92
89
|
input: itemsIdsArray.map((collectionId) => {
|
|
@@ -132,7 +129,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
132
129
|
itemType,
|
|
133
130
|
page: {
|
|
134
131
|
token: pageToken,
|
|
135
|
-
...(page &&
|
|
132
|
+
...(page && "size" in page ? { size: page.size } : {}),
|
|
136
133
|
},
|
|
137
134
|
},
|
|
138
135
|
updateQuery: (previousQueryResult) => {
|
|
@@ -142,7 +139,7 @@ const useGetCreationsAndLikesByType = ({ itemType, page, }) => {
|
|
|
142
139
|
const { creations: nextCreations, ...token } = data.fetchCreationsByType;
|
|
143
140
|
setAllCreations((prevCreations) => [
|
|
144
141
|
...prevCreations,
|
|
145
|
-
...nextCreations.map((creation) =>
|
|
142
|
+
...nextCreations.map((creation) => (0, builder_1.buildCreation)(creation)),
|
|
146
143
|
]);
|
|
147
144
|
setNextPageToken(token.nextPage?.token || null);
|
|
148
145
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
declare const useGetMixedLikesFavoriteList: ({ galleryId, itemsCount, }: {
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { searchSchema as schema } from "@ludo.ninja/api";
|
|
3
|
+
declare const useGetMixedLikesFavoriteList: ({ galleryId, itemsCount }: {
|
|
5
4
|
galleryId: string;
|
|
6
5
|
itemsCount: number | null;
|
|
7
6
|
}) => {
|
|
8
|
-
gallery: import("../../../
|
|
9
|
-
creationsList: []
|
|
7
|
+
gallery: import("../../../entities/gallery/types").TGallery[] | null;
|
|
8
|
+
creationsList: TCreation[];
|
|
10
9
|
likes: (schema.IDynamicAssetData | schema.IDynamicCollectionData)[];
|
|
11
10
|
allResults: number | null;
|
|
12
11
|
loading: boolean;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const useGetFavoriteGallaryCreations_1 = require("../../favorites/useGetFavoriteGallaryCreations");
|
|
5
3
|
const useGetTableLikes_1 = require("./useGetTableLikes");
|
|
6
|
-
const
|
|
4
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
5
|
+
const useGetFavoriteGallaryCreations_1 = require("../../favorites/useGetFavoriteGallaryCreations");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const useGetMixedLikesFavoriteList = ({ galleryId, itemsCount }) => {
|
|
7
8
|
const [likes, setLikes] = (0, react_1.useState)([]);
|
|
8
9
|
const [creationsList, setCreationsList] = (0, react_1.useState)([]);
|
|
9
10
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
@@ -17,20 +18,18 @@ const useGetMixedLikesFavoriteList = ({ galleryId, itemsCount, }) => {
|
|
|
17
18
|
if (!creationsLoading && !loadingLikes) {
|
|
18
19
|
const combinedLikes = [];
|
|
19
20
|
fetchedCreationsList.forEach((item) => {
|
|
20
|
-
if (item.
|
|
21
|
-
combinedLikes.push(...assetsLikes.filter((like) => like.assetId === item.
|
|
21
|
+
if (item.itemType === types_1.LabelKeys.asset) {
|
|
22
|
+
combinedLikes.push(...assetsLikes.filter((like) => like.assetId === item.itemId));
|
|
22
23
|
}
|
|
23
24
|
else {
|
|
24
|
-
combinedLikes.push(...collectionsLikes.filter((like) => like.collectionId === item.
|
|
25
|
+
combinedLikes.push(...collectionsLikes.filter((like) => like.collectionId === item.creationId));
|
|
25
26
|
}
|
|
26
27
|
});
|
|
27
28
|
creationsList.length !== combinedLikes.length &&
|
|
28
29
|
setLikes(combinedLikes);
|
|
29
|
-
creationsList.length !== combinedLikes.length &&
|
|
30
|
-
setCreationsList(fetchedCreationsList);
|
|
30
|
+
creationsList.length !== combinedLikes.length && setCreationsList(fetchedCreationsList);
|
|
31
31
|
fetchedCreationsList.length === combinedLikes.length && setLoading(false);
|
|
32
|
-
creationsList.length === fetchedCreationsList.length &&
|
|
33
|
-
setAllItemsFetched(true);
|
|
32
|
+
creationsList.length === fetchedCreationsList.length && setAllItemsFetched(true);
|
|
34
33
|
}
|
|
35
34
|
}, [creationsLoading, JSON.stringify(fetchedCreationsList), loadingLikes]);
|
|
36
35
|
return {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
allItems: Array<CreationEntity | CollectionCreationEntity>;
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { searchSchema as schema } from "@ludo.ninja/api";
|
|
3
|
+
declare const useGetTableLikes: ({ allItems }: {
|
|
4
|
+
allItems: Array<TCreation>;
|
|
6
5
|
}) => {
|
|
7
6
|
fetchAssetsLikes: import("@apollo/client").LazyQueryExecFunction<any, import("@apollo/client").OperationVariables>;
|
|
8
7
|
fetchCollectionsLikes: import("@apollo/client").LazyQueryExecFunction<any, import("@apollo/client").OperationVariables>;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useGetTableLikes = void 0;
|
|
7
|
-
const
|
|
4
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
5
|
+
const ui_1 = require("../../../store/ui");
|
|
8
6
|
const client_1 = require("@apollo/client");
|
|
9
7
|
const api_1 = require("@ludo.ninja/api");
|
|
10
8
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
14
|
-
const useGetTableLikes = ({ allItems, }) => {
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const useGetTableLikes = ({ allItems }) => {
|
|
15
11
|
const [assetsLikes, setAssetsLikes] = (0, react_1.useState)([]);
|
|
16
12
|
const [collectionsLikes, setCollectionsLikes] = (0, react_1.useState)([]);
|
|
17
13
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
@@ -25,7 +21,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
25
21
|
context: {
|
|
26
22
|
uri: api_1.hosts.searchHost,
|
|
27
23
|
},
|
|
28
|
-
fetchPolicy:
|
|
24
|
+
fetchPolicy: "no-cache",
|
|
29
25
|
onCompleted: ({ fetchDynamicAssetsData }) => {
|
|
30
26
|
setAssetsLikes(fetchDynamicAssetsData);
|
|
31
27
|
activeRequestsCount.current -= 1;
|
|
@@ -34,7 +30,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
34
30
|
onError: () => {
|
|
35
31
|
openAlert({
|
|
36
32
|
type: type_1.alertVariants.error,
|
|
37
|
-
caption:
|
|
33
|
+
caption: "Oops, something went wrong.",
|
|
38
34
|
});
|
|
39
35
|
setAssetsLikes([]);
|
|
40
36
|
activeRequestsCount.current -= 1;
|
|
@@ -45,7 +41,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
45
41
|
// loading: collectionsLoading
|
|
46
42
|
},] = (0, client_1.useLazyQuery)(api_1.searchSchema.FetchDynamicCollectionsDataDocument, {
|
|
47
43
|
context: { uri: api_1.hosts.searchHost },
|
|
48
|
-
fetchPolicy:
|
|
44
|
+
fetchPolicy: "no-cache",
|
|
49
45
|
onCompleted: ({ fetchDynamicCollectionsData }) => {
|
|
50
46
|
setCollectionsLikes(fetchDynamicCollectionsData);
|
|
51
47
|
activeRequestsCount.current -= 1;
|
|
@@ -54,7 +50,7 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
54
50
|
onError: () => {
|
|
55
51
|
openAlert({
|
|
56
52
|
type: type_1.alertVariants.error,
|
|
57
|
-
caption:
|
|
53
|
+
caption: "Oops, something went wrong.",
|
|
58
54
|
});
|
|
59
55
|
setCollectionsLikes([]);
|
|
60
56
|
activeRequestsCount.current -= 1;
|
|
@@ -71,23 +67,20 @@ const useGetTableLikes = ({ allItems, }) => {
|
|
|
71
67
|
const assetIds = [];
|
|
72
68
|
const collectionIds = [];
|
|
73
69
|
allItems.forEach((item) => {
|
|
74
|
-
if (item
|
|
75
|
-
assetIds.push(item.
|
|
70
|
+
if (item.itemType === types_1.LabelKeys.asset) {
|
|
71
|
+
assetIds.push(item.itemId);
|
|
76
72
|
}
|
|
77
|
-
else if (item
|
|
78
|
-
collectionIds.push(item.
|
|
73
|
+
else if (item.itemType === types_1.LabelKeys.collection) {
|
|
74
|
+
collectionIds.push(item.creationId);
|
|
79
75
|
}
|
|
80
76
|
});
|
|
81
|
-
if (assetIds.length > 0 &&
|
|
82
|
-
JSON.stringify(assetIds) !== JSON.stringify(prevAssetsIds.current)) {
|
|
77
|
+
if (assetIds.length > 0 && JSON.stringify(assetIds) !== JSON.stringify(prevAssetsIds.current)) {
|
|
83
78
|
prevAssetsIds.current = assetIds;
|
|
84
79
|
activeRequestsCount.current += 1;
|
|
85
80
|
!loading && setLoading(true);
|
|
86
81
|
fetchAssetsLikes({ variables: { assetIds } });
|
|
87
82
|
}
|
|
88
|
-
if (collectionIds.length > 0 &&
|
|
89
|
-
JSON.stringify(collectionIds) !==
|
|
90
|
-
JSON.stringify(prevCollectionsIds.current)) {
|
|
83
|
+
if (collectionIds.length > 0 && JSON.stringify(collectionIds) !== JSON.stringify(prevCollectionsIds.current)) {
|
|
91
84
|
prevCollectionsIds.current = collectionIds;
|
|
92
85
|
activeRequestsCount.current += 1;
|
|
93
86
|
!loading && setLoading(true);
|
|
@@ -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 {
|
|
3
|
-
import { TActiveTab } from '../../../system/Tabs/TabsNav/type';
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { TGallery } from '../../../entities/gallery/types';
|
|
4
3
|
import { TCurrentItemType } from '../../../hooks/likes/useGetLikesAsset';
|
|
5
4
|
import { TOpportunity } from '../../opportunity/type';
|
|
6
|
-
|
|
5
|
+
import { TActiveTab } from '../../../system/Tabs/TabsNav/type';
|
|
6
|
+
export type TCreationWithOpportunity = TCreation | 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
|
}) => {
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useGetAssetsAndCollectionForFavorite = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
12
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
13
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
4
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
5
|
+
const collectionCreationBuilder_1 = require("../../../entities/creation/collectionCreationBuilder");
|
|
6
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
7
|
+
const store_1 = require("../store");
|
|
14
8
|
const ui_1 = require("../../../store/ui");
|
|
15
9
|
const extractItemIds_1 = require("../../../utils/extractItemIds");
|
|
16
10
|
const getPageSizeAssets_1 = require("../../../utils/getPageSizeAssets");
|
|
17
|
-
const
|
|
11
|
+
const client_1 = require("@apollo/client");
|
|
12
|
+
const api_1 = require("@ludo.ninja/api");
|
|
13
|
+
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
14
|
+
const react_1 = require("react");
|
|
18
15
|
const limit = 40;
|
|
19
16
|
const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes, }) => {
|
|
20
17
|
const [assets, setAssets] = (0, react_1.useState)([]);
|
|
@@ -36,25 +33,23 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
36
33
|
})
|
|
37
34
|
: limit;
|
|
38
35
|
const totalLength = size !== limit ? size : false;
|
|
39
|
-
const creationIds = gallery.
|
|
36
|
+
const creationIds = gallery.creationIds;
|
|
40
37
|
const startIndex = (currentPageRef.current - 1) * limit;
|
|
41
38
|
const endIndex = totalLength ? totalLength : startIndex + limit;
|
|
42
39
|
for (let i = startIndex; i < endIndex && i < creationIds.length; i++) {
|
|
43
|
-
const elements = creationIds[i].split(
|
|
44
|
-
const id = elements.splice(1, creationIds[i].length).join(
|
|
45
|
-
if (elements[0] ===
|
|
40
|
+
const elements = creationIds[i].split(".");
|
|
41
|
+
const id = elements.splice(1, creationIds[i].length).join(".");
|
|
42
|
+
if (elements[0] === "asset") {
|
|
46
43
|
assetArray.push(id);
|
|
47
44
|
}
|
|
48
|
-
else if (elements[0] ===
|
|
45
|
+
else if (elements[0] === "collection") {
|
|
49
46
|
collectionsArray.push(id);
|
|
50
47
|
}
|
|
51
|
-
else if (elements[0] ===
|
|
48
|
+
else if (elements[0] === "opportunity") {
|
|
52
49
|
opportunitiesArray.push(id);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
const assetPromise = assetArray.length > 0
|
|
56
|
-
? fetchAssets({ variables: { assetIds: assetArray } })
|
|
57
|
-
: Promise.resolve();
|
|
52
|
+
const assetPromise = assetArray.length > 0 ? fetchAssets({ variables: { assetIds: assetArray } }) : Promise.resolve();
|
|
58
53
|
const collectionsPromise = collectionsArray.length > 0
|
|
59
54
|
? fetchCollections({ variables: { collectionIds: collectionsArray } })
|
|
60
55
|
: Promise.resolve();
|
|
@@ -79,74 +74,71 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
79
74
|
}
|
|
80
75
|
}
|
|
81
76
|
};
|
|
82
|
-
const [fetchAssets, { error: assetsError, refetch: refetchAssets }] = (0, client_1.useLazyQuery)(
|
|
77
|
+
const [fetchAssets, { error: assetsError, refetch: refetchAssets }] = (0, client_1.useLazyQuery)(api_1.searchSchema.FetchAssetsDocument, {
|
|
83
78
|
context: { uri: api_1.hosts.searchHost },
|
|
84
|
-
fetchPolicy:
|
|
79
|
+
fetchPolicy: "no-cache",
|
|
85
80
|
onCompleted: ({ fetchAssets: data }) => {
|
|
86
81
|
setAssets((prevAssets) => {
|
|
87
82
|
const results = [
|
|
88
83
|
...(prevAssets || []),
|
|
89
84
|
...data.map((asset) => [
|
|
90
85
|
asset.assetId,
|
|
91
|
-
|
|
86
|
+
(0, builder_1.buildCreation)({
|
|
92
87
|
...asset,
|
|
93
|
-
itemType:
|
|
88
|
+
itemType: "asset",
|
|
94
89
|
itemId: asset.assetId,
|
|
95
90
|
}),
|
|
96
91
|
]),
|
|
97
92
|
];
|
|
98
|
-
getLikesForAllCreations(results.map((el) => el[1]),
|
|
93
|
+
getLikesForAllCreations(results.map((el) => el[1]), "asset");
|
|
99
94
|
return results;
|
|
100
95
|
});
|
|
101
96
|
},
|
|
102
97
|
onError: () => {
|
|
103
98
|
openAlert({
|
|
104
99
|
type: type_1.alertVariants.error,
|
|
105
|
-
caption:
|
|
100
|
+
caption: "Oops, something went wrong.",
|
|
106
101
|
});
|
|
107
102
|
setAssets([]);
|
|
108
103
|
},
|
|
109
104
|
});
|
|
110
|
-
const [fetchCollections, { error: collectionsError, refetch: refetchCollections }
|
|
105
|
+
const [fetchCollections, { error: collectionsError, refetch: refetchCollections }] = (0, client_1.useLazyQuery)(api_1.searchSchema.FetchCollectionsByIdsDocument, {
|
|
111
106
|
context: { uri: api_1.hosts.searchHost },
|
|
112
|
-
fetchPolicy:
|
|
107
|
+
fetchPolicy: "no-cache",
|
|
113
108
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
114
109
|
setCollections((prevCollections) => {
|
|
115
110
|
const results = [
|
|
116
111
|
...(prevCollections || []),
|
|
117
112
|
...data.map((collection) => [
|
|
118
113
|
collection.collectionId,
|
|
119
|
-
|
|
114
|
+
(0, collectionCreationBuilder_1.buildCollectionCreation)(collection, types_1.LabelKeys.collection),
|
|
120
115
|
]),
|
|
121
116
|
];
|
|
122
|
-
getLikesForAllCreations(results.map((el) => el[1]),
|
|
117
|
+
getLikesForAllCreations(results.map((el) => el[1]), "collection");
|
|
123
118
|
return results;
|
|
124
119
|
});
|
|
125
120
|
},
|
|
126
121
|
onError: () => {
|
|
127
122
|
openAlert({
|
|
128
123
|
type: type_1.alertVariants.error,
|
|
129
|
-
caption:
|
|
124
|
+
caption: "Oops, something went wrong.",
|
|
130
125
|
});
|
|
131
126
|
setCollections([]);
|
|
132
127
|
},
|
|
133
128
|
});
|
|
134
|
-
const [fetchOpportunities, { error: opportunitiesError, refetch: refetchOpportunities }
|
|
129
|
+
const [fetchOpportunities, { error: opportunitiesError, refetch: refetchOpportunities }] = api_1.opportunitiesSchema.useFetchOpportunitiesByIdsLazyQuery({
|
|
135
130
|
context: { uri: api_1.hosts.opportunitiesHost },
|
|
136
|
-
fetchPolicy:
|
|
131
|
+
fetchPolicy: "no-cache",
|
|
137
132
|
onCompleted: ({ fetchOpportunitiesByIds: data }) => {
|
|
138
133
|
setOpportunities((prev) => [
|
|
139
134
|
...(prev || []),
|
|
140
|
-
...data.map((opportunity) => [
|
|
141
|
-
opportunity.opportunityId,
|
|
142
|
-
opportunity,
|
|
143
|
-
]),
|
|
135
|
+
...data.map((opportunity) => [opportunity.opportunityId, opportunity]),
|
|
144
136
|
]);
|
|
145
137
|
},
|
|
146
138
|
onError: () => {
|
|
147
139
|
openAlert({
|
|
148
140
|
type: type_1.alertVariants.error,
|
|
149
|
-
caption:
|
|
141
|
+
caption: "Oops, something went wrong.",
|
|
150
142
|
});
|
|
151
143
|
setOpportunities([]);
|
|
152
144
|
},
|
|
@@ -166,22 +158,22 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
166
158
|
});
|
|
167
159
|
};
|
|
168
160
|
const creations = (0, react_1.useMemo)(() => {
|
|
169
|
-
const creationIds = gallery.
|
|
161
|
+
const creationIds = gallery.creationIds;
|
|
170
162
|
const mapAssets = new Map(assets);
|
|
171
163
|
const collectionAssets = new Map(collections);
|
|
172
164
|
const opportunityAssets = new Map(opportunities);
|
|
173
165
|
return creationIds
|
|
174
166
|
.map((id) => {
|
|
175
|
-
const idSplit = id.split(
|
|
167
|
+
const idSplit = id.split(".");
|
|
176
168
|
const idType = idSplit[0];
|
|
177
|
-
const idElement = idSplit.slice(1).join(
|
|
178
|
-
if (idType ===
|
|
169
|
+
const idElement = idSplit.slice(1).join(".");
|
|
170
|
+
if (idType === "asset") {
|
|
179
171
|
return mapAssets.get(idElement);
|
|
180
172
|
}
|
|
181
|
-
if (idType ===
|
|
173
|
+
if (idType === "collection") {
|
|
182
174
|
return collectionAssets.get(idElement);
|
|
183
175
|
}
|
|
184
|
-
if (idType ===
|
|
176
|
+
if (idType === "opportunity") {
|
|
185
177
|
return opportunityAssets.get(idElement);
|
|
186
178
|
}
|
|
187
179
|
})
|
|
@@ -206,13 +198,13 @@ const useGetAssetsAndCollectionForFavorite = ({ gallery, activeTab, fetchLikes,
|
|
|
206
198
|
}
|
|
207
199
|
},
|
|
208
200
|
removeCreation: (creationIdToRemove, itemType) => {
|
|
209
|
-
if (itemType ===
|
|
201
|
+
if (itemType === "asset") {
|
|
210
202
|
setAssets((items) => items.filter((item) => item[0] !== creationIdToRemove));
|
|
211
203
|
}
|
|
212
|
-
if (itemType ===
|
|
204
|
+
if (itemType === "collection") {
|
|
213
205
|
setCollections((items) => items.filter((item) => item[0] !== creationIdToRemove));
|
|
214
206
|
}
|
|
215
|
-
if (itemType ===
|
|
207
|
+
if (itemType === "opportunity") {
|
|
216
208
|
setOpportunities((items) => items.filter((item) => item[0] !== creationIdToRemove));
|
|
217
209
|
}
|
|
218
210
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { TGallery } from '../../entities/gallery/types';
|
|
2
|
+
import { galleriesSchema as schema } from "@ludo.ninja/api";
|
|
3
3
|
type UserFields = {
|
|
4
4
|
galleryName: string;
|
|
5
5
|
galleryDescription: string;
|
|
@@ -9,7 +9,7 @@ export interface HTMLInputEvent extends Event {
|
|
|
9
9
|
}
|
|
10
10
|
interface IFavoriteStore {
|
|
11
11
|
fetchGalleryV2: schema.IGalleryV2 | null;
|
|
12
|
-
gallery:
|
|
12
|
+
gallery: TGallery | null;
|
|
13
13
|
setGallery: (gallery: schema.IGalleryV2 | null) => void;
|
|
14
14
|
updateGalleryInfo: (data: UserFields) => void;
|
|
15
15
|
updateGalleryBanner: (banner: string | null) => void;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.useGalleryStore = void 0;
|
|
4
|
+
const builder_1 = require("../../entities/gallery/builder");
|
|
7
5
|
const getDimensionsImage_1 = require("../../utils/getDimensionsImage");
|
|
8
6
|
const shallow_1 = require("zustand/shallow");
|
|
9
7
|
const traditional_1 = require("zustand/traditional");
|
|
10
|
-
const GalleryEntityV2_1 = __importDefault(require("../../dto/GalleryEntityV2"));
|
|
11
8
|
const initialState = {
|
|
12
9
|
gallery: null,
|
|
13
10
|
fetchGalleryV2: null,
|
|
@@ -20,7 +17,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
|
|
|
20
17
|
setGallery: (gallery) => {
|
|
21
18
|
if (gallery) {
|
|
22
19
|
setState({
|
|
23
|
-
gallery:
|
|
20
|
+
gallery: (0, builder_1.buildGallery)(gallery),
|
|
24
21
|
fetchGalleryV2: gallery,
|
|
25
22
|
});
|
|
26
23
|
}
|
|
@@ -37,7 +34,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
|
|
|
37
34
|
};
|
|
38
35
|
return {
|
|
39
36
|
fetchGalleryV2: newGallery,
|
|
40
|
-
gallery:
|
|
37
|
+
gallery: (0, builder_1.buildGallery)(newGallery),
|
|
41
38
|
};
|
|
42
39
|
});
|
|
43
40
|
},
|
|
@@ -49,11 +46,11 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
|
|
|
49
46
|
};
|
|
50
47
|
return {
|
|
51
48
|
fetchGalleryV2: newGallery,
|
|
52
|
-
gallery:
|
|
49
|
+
gallery: (0, builder_1.buildGallery)(newGallery),
|
|
53
50
|
};
|
|
54
51
|
});
|
|
55
52
|
},
|
|
56
|
-
fileGallery:
|
|
53
|
+
fileGallery: "",
|
|
57
54
|
isErrorFileGallery: initialState.isErrorFileGallery,
|
|
58
55
|
addFileGalleryWithValidation: async (e) => {
|
|
59
56
|
const fileTarget = e.target.files?.[0];
|
|
@@ -68,8 +65,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
|
|
|
68
65
|
}
|
|
69
66
|
else {
|
|
70
67
|
const dimensions = await (0, getDimensionsImage_1.getDimensionsImage)(fileTarget);
|
|
71
|
-
const isErrorNew = !!(dimensions &&
|
|
72
|
-
(dimensions.width > 1200 || dimensions.height > 1200));
|
|
68
|
+
const isErrorNew = !!(dimensions && (dimensions.width > 1200 || dimensions.height > 1200));
|
|
73
69
|
setState({ isErrorFileGallery: isErrorNew });
|
|
74
70
|
if (isErrorNew) {
|
|
75
71
|
return;
|
|
@@ -84,7 +80,7 @@ exports.useGalleryStore = (0, traditional_1.createWithEqualityFn)()((setState, g
|
|
|
84
80
|
const fileGallery = getState().fileGallery;
|
|
85
81
|
if (fileGallery) {
|
|
86
82
|
URL.revokeObjectURL(fileGallery);
|
|
87
|
-
setState({ fileGallery:
|
|
83
|
+
setState({ fileGallery: "" });
|
|
88
84
|
}
|
|
89
85
|
},
|
|
90
86
|
allResults: initialState.allResults,
|