@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,22 +1,19 @@
|
|
|
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.useGetUserGalleriesCreations = void 0;
|
|
7
4
|
exports.getMediaForGallery = getMediaForGallery;
|
|
8
|
-
const
|
|
5
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
6
|
+
const collectionCreationBuilder_1 = require("../../../entities/creation/collectionCreationBuilder");
|
|
7
|
+
const builder_2 = require("../../../entities/gallery/builder");
|
|
8
|
+
const ui_1 = require("../../../store/ui");
|
|
9
9
|
const client_1 = require("@apollo/client");
|
|
10
10
|
const api_1 = require("@ludo.ninja/api");
|
|
11
11
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema");
|
|
12
12
|
const schema_2 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
13
13
|
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"));
|
|
14
|
+
const react_1 = require("react");
|
|
18
15
|
const maxUserFavoritesLength = 1000;
|
|
19
|
-
const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken
|
|
16
|
+
const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken }) => {
|
|
20
17
|
const [assets, setAsset] = (0, react_1.useState)(null);
|
|
21
18
|
const [collections, setCollections] = (0, react_1.useState)(null);
|
|
22
19
|
const [galleries, setGalleries] = (0, react_1.useState)([]);
|
|
@@ -29,17 +26,17 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
29
26
|
const { loading: favoritesLoading, error: galleriesError, refetch, fetchMore, } = (0, client_1.useQuery)(schema_1.FetchUserGalleriesV2Document, {
|
|
30
27
|
context: { uri: api_1.hosts.galleriesHost },
|
|
31
28
|
variables: { pageSize, userId, pageToken },
|
|
32
|
-
fetchPolicy:
|
|
33
|
-
onCompleted: ({ fetchUserGalleriesV2: { galleries, nextPageToken: token }
|
|
29
|
+
fetchPolicy: "no-cache",
|
|
30
|
+
onCompleted: ({ fetchUserGalleriesV2: { galleries, nextPageToken: token } }) => {
|
|
34
31
|
// nextPageToken.current = nextPage.nextPage?.token || null;
|
|
35
32
|
nextPageToken.current = token || null;
|
|
36
|
-
setGalleries(galleries.map((gallery) =>
|
|
33
|
+
setGalleries(galleries.map((gallery) => (0, builder_2.buildGallery)(gallery)));
|
|
37
34
|
setLoading(false);
|
|
38
35
|
},
|
|
39
36
|
onError: () => {
|
|
40
37
|
openAlert({
|
|
41
38
|
type: type_1.alertVariants.error,
|
|
42
|
-
caption:
|
|
39
|
+
caption: "Oops, something went wrong while fetching galleries.",
|
|
43
40
|
});
|
|
44
41
|
setGalleries([]);
|
|
45
42
|
setLoading(false);
|
|
@@ -47,11 +44,11 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
47
44
|
});
|
|
48
45
|
const [fetchAssets, { loading: assetsLoading, error: assetsError }] = (0, client_1.useLazyQuery)(schema_2.FetchAssetsDocument, {
|
|
49
46
|
context: { uri: api_1.hosts.searchHost },
|
|
50
|
-
fetchPolicy:
|
|
47
|
+
fetchPolicy: "no-cache",
|
|
51
48
|
onCompleted: ({ fetchAssets: data }) => {
|
|
52
|
-
setAsset(data.map((asset) =>
|
|
49
|
+
setAsset(data.map((asset) => (0, builder_1.buildCreation)({
|
|
53
50
|
...asset,
|
|
54
|
-
itemType:
|
|
51
|
+
itemType: "asset",
|
|
55
52
|
itemId: asset.assetId,
|
|
56
53
|
})));
|
|
57
54
|
setLoading(false);
|
|
@@ -59,23 +56,23 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
59
56
|
onError: () => {
|
|
60
57
|
openAlert({
|
|
61
58
|
type: type_1.alertVariants.error,
|
|
62
|
-
caption:
|
|
59
|
+
caption: "Oops, something went wrong.",
|
|
63
60
|
});
|
|
64
61
|
setAsset(null);
|
|
65
62
|
setLoading(false);
|
|
66
63
|
},
|
|
67
64
|
});
|
|
68
|
-
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }
|
|
65
|
+
const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
|
|
69
66
|
context: { uri: api_1.hosts.searchHost },
|
|
70
|
-
fetchPolicy:
|
|
67
|
+
fetchPolicy: "no-cache",
|
|
71
68
|
onCompleted: ({ fetchCollectionsByIds: data }) => {
|
|
72
|
-
setCollections(data.map((collection) =>
|
|
69
|
+
setCollections(data.map((collection) => (0, collectionCreationBuilder_1.buildCollectionCreation)(collection)));
|
|
73
70
|
setLoading(false);
|
|
74
71
|
},
|
|
75
72
|
onError: () => {
|
|
76
73
|
openAlert({
|
|
77
74
|
type: type_1.alertVariants.error,
|
|
78
|
-
caption:
|
|
75
|
+
caption: "Oops, something went wrong.",
|
|
79
76
|
});
|
|
80
77
|
setCollections(null);
|
|
81
78
|
setLoading(false);
|
|
@@ -96,9 +93,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
96
93
|
await refetch();
|
|
97
94
|
}
|
|
98
95
|
async function loadMoreGalleriesList() {
|
|
99
|
-
if (!nextPageToken.current ||
|
|
100
|
-
!isHaveNextPage ||
|
|
101
|
-
galleries.length >= maxUserFavoritesLength)
|
|
96
|
+
if (!nextPageToken.current || !isHaveNextPage || galleries.length >= maxUserFavoritesLength)
|
|
102
97
|
return;
|
|
103
98
|
setIsNextLoading(true);
|
|
104
99
|
await fetchMore({
|
|
@@ -108,7 +103,7 @@ const useGetUserGalleriesCreations = ({ userId, pageSize, pageToken, }) => {
|
|
|
108
103
|
return prev;
|
|
109
104
|
const { nextPageToken: token, galleries: nextGalleries } = fetchMoreResult.fetchMyFavoritesV2;
|
|
110
105
|
nextPageToken.current = token || null;
|
|
111
|
-
if (prev !== null && prev.hasOwnProperty(
|
|
106
|
+
if (prev !== null && prev.hasOwnProperty("fetchMyGalleriesV2")) {
|
|
112
107
|
const { galleries: prevGalleries } = prev.fetchMyGalleriesV2;
|
|
113
108
|
return {
|
|
114
109
|
fetchMyGalleriesV2: {
|
|
@@ -151,24 +146,16 @@ function getMediaForGallery(favorites, takeFirstFour) {
|
|
|
151
146
|
const assetArray = [];
|
|
152
147
|
const collectionsArray = [];
|
|
153
148
|
favorites.forEach((fav) => {
|
|
154
|
-
const creationIds = takeFirstFour
|
|
155
|
-
? fav.getGalleryCreationIds().slice(0, 4)
|
|
156
|
-
: fav.getGalleryCreationIds();
|
|
149
|
+
const creationIds = takeFirstFour ? fav.creationIds.slice(0, 4) : fav.creationIds;
|
|
157
150
|
if (!creationIds || creationIds.length === 0)
|
|
158
151
|
return;
|
|
159
152
|
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('.');
|
|
153
|
+
if (creationIds[i].split(".")[0] === "asset") {
|
|
154
|
+
const assetId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
|
|
165
155
|
assetArray.push(assetId);
|
|
166
156
|
}
|
|
167
|
-
else if (creationIds[i].split(
|
|
168
|
-
const collectionId = creationIds[i]
|
|
169
|
-
.split('.')
|
|
170
|
-
.splice(1, creationIds[i].length)
|
|
171
|
-
.join('.');
|
|
157
|
+
else if (creationIds[i].split(".")[0] === "collection") {
|
|
158
|
+
const collectionId = creationIds[i].split(".").splice(1, creationIds[i].length).join(".");
|
|
172
159
|
collectionsArray.push(collectionId);
|
|
173
160
|
}
|
|
174
161
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
export declare const useFindCollectionsAndLikes: ({ term, input, page
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { IDynamicCollectionData, IQueryFindCollectionsArgs } from "@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema";
|
|
3
|
+
export declare const useFindCollectionsAndLikes: ({ term, input, page }: IQueryFindCollectionsArgs) => {
|
|
4
4
|
loadMore: (pageToken: string) => Promise<void>;
|
|
5
5
|
loading: boolean;
|
|
6
6
|
collectionsLoading: boolean;
|
|
@@ -8,12 +8,12 @@ export declare const useFindCollectionsAndLikes: ({ term, input, page, }: IQuery
|
|
|
8
8
|
collectionsLikes: [] | IDynamicCollectionData[];
|
|
9
9
|
error: import("@apollo/client").ApolloError | undefined;
|
|
10
10
|
results: number;
|
|
11
|
-
collections:
|
|
11
|
+
collections: TCreation[];
|
|
12
12
|
nextPageToken: string | null;
|
|
13
13
|
refetchQuery: () => Promise<void>;
|
|
14
14
|
};
|
|
15
15
|
declare const _default: {
|
|
16
|
-
useFindCollectionsAndLikes: ({ term, input, page
|
|
16
|
+
useFindCollectionsAndLikes: ({ term, input, page }: IQueryFindCollectionsArgs) => {
|
|
17
17
|
loadMore: (pageToken: string) => Promise<void>;
|
|
18
18
|
loading: boolean;
|
|
19
19
|
collectionsLoading: boolean;
|
|
@@ -21,7 +21,7 @@ declare const _default: {
|
|
|
21
21
|
collectionsLikes: [] | IDynamicCollectionData[];
|
|
22
22
|
error: import("@apollo/client").ApolloError | undefined;
|
|
23
23
|
results: number;
|
|
24
|
-
collections:
|
|
24
|
+
collections: TCreation[];
|
|
25
25
|
nextPageToken: string | null;
|
|
26
26
|
refetchQuery: () => Promise<void>;
|
|
27
27
|
};
|
|
@@ -1,17 +1,15 @@
|
|
|
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.useFindCollectionsAndLikes = void 0;
|
|
7
|
-
const
|
|
4
|
+
const collectionCreationBuilder_1 = require("../../../entities/creation/collectionCreationBuilder");
|
|
5
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
6
|
+
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
7
|
+
const ui_1 = require("../../../store/ui");
|
|
8
8
|
const client_1 = require("@apollo/client");
|
|
9
9
|
const api_1 = require("@ludo.ninja/api");
|
|
10
10
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
11
11
|
const type_1 = require("@ludo.ninja/ui/build/system/Alert/type");
|
|
12
|
-
const
|
|
13
|
-
const ui_1 = require("../../../store/ui");
|
|
14
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
12
|
+
const react_1 = require("react");
|
|
15
13
|
// export const prefetchFindCollections = (
|
|
16
14
|
// { term, input, pageSize, pageToken }: schema.IQueryFindCollectionsArgs,
|
|
17
15
|
// apolloClient: ApolloClient<NormalizedCacheObject>
|
|
@@ -30,7 +28,7 @@ const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collect
|
|
|
30
28
|
// });
|
|
31
29
|
// };
|
|
32
30
|
const maxCollectionsLength = 1000;
|
|
33
|
-
const useFindCollectionsAndLikes = ({ term, input, page
|
|
31
|
+
const useFindCollectionsAndLikes = ({ term, input, page }) => {
|
|
34
32
|
const [collections, setCollections] = (0, react_1.useState)([]);
|
|
35
33
|
const [nextPageToken, setNextPageToken] = (0, react_1.useState)(null);
|
|
36
34
|
const [results, setResults] = (0, react_1.useState)(0);
|
|
@@ -38,7 +36,7 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
38
36
|
const [collectionsLikes, setCollectionsLikes] = (0, react_1.useState)([]);
|
|
39
37
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
40
38
|
const { error, loading: collectionsLoading, fetchMore, refetch, } = (0, schema_1.useFindCollectionsQuery)({
|
|
41
|
-
fetchPolicy:
|
|
39
|
+
fetchPolicy: "no-cache",
|
|
42
40
|
context: {
|
|
43
41
|
uri: api_1.hosts.searchHost,
|
|
44
42
|
},
|
|
@@ -48,10 +46,10 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
48
46
|
page,
|
|
49
47
|
},
|
|
50
48
|
onCompleted: ({ findCollections: { collections, ...nextPage } }) => {
|
|
51
|
-
setCollections(collections.map((collection) =>
|
|
49
|
+
setCollections(collections.map((collection) => (0, collectionCreationBuilder_1.buildCollectionCreation)({
|
|
52
50
|
...collection,
|
|
53
51
|
name: collection && collection.collectionTitle,
|
|
54
|
-
},
|
|
52
|
+
}, types_1.LabelKeys.collection)));
|
|
55
53
|
if (!collections.length) {
|
|
56
54
|
setLoading(false);
|
|
57
55
|
}
|
|
@@ -61,7 +59,7 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
61
59
|
onError: () => {
|
|
62
60
|
openAlert({
|
|
63
61
|
type: type_1.alertVariants.error,
|
|
64
|
-
caption:
|
|
62
|
+
caption: "Oops, something went wrong.",
|
|
65
63
|
});
|
|
66
64
|
setCollections([]);
|
|
67
65
|
setNextPageToken(null);
|
|
@@ -73,11 +71,11 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
73
71
|
setCollectionsLikes(fetchDynamicCollectionsData);
|
|
74
72
|
setLoading(false);
|
|
75
73
|
},
|
|
76
|
-
fetchPolicy:
|
|
74
|
+
fetchPolicy: "no-cache",
|
|
77
75
|
onError: () => {
|
|
78
76
|
openAlert({
|
|
79
77
|
type: type_1.alertVariants.error,
|
|
80
|
-
caption:
|
|
78
|
+
caption: "Oops, something went wrong when fetch collections likes.",
|
|
81
79
|
});
|
|
82
80
|
setCollectionsLikes([]);
|
|
83
81
|
setLoading(false);
|
|
@@ -87,7 +85,7 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
87
85
|
if (collections.length > 0) {
|
|
88
86
|
const itemsIdsArray = (0, useGetCreationsAndLikes_1.extractItemIds)(collections);
|
|
89
87
|
if (itemsIdsArray.length > 0) {
|
|
90
|
-
if (collections[0].
|
|
88
|
+
if (collections[0].itemType === types_1.LabelKeys.collection) {
|
|
91
89
|
fetchCollectionsLikes({
|
|
92
90
|
variables: {
|
|
93
91
|
input: itemsIdsArray.map((collectionId) => {
|
|
@@ -136,10 +134,10 @@ const useFindCollectionsAndLikes = ({ term, input, page, }) => {
|
|
|
136
134
|
},
|
|
137
135
|
});
|
|
138
136
|
const { collections: nextCollections, ...nextPage } = data.findCollections;
|
|
139
|
-
const nextList = nextCollections.map((collectionAsset) =>
|
|
137
|
+
const nextList = nextCollections.map((collectionAsset) => (0, collectionCreationBuilder_1.buildCollectionCreation)({
|
|
140
138
|
...collectionAsset,
|
|
141
139
|
name: collectionAsset && collectionAsset.collectionTitle,
|
|
142
|
-
},
|
|
140
|
+
}, types_1.LabelKeys.collection));
|
|
143
141
|
setCollections((prevCollection) => [...prevCollection, ...nextList]);
|
|
144
142
|
setResults(nextPage.nextPage?.elements || 0);
|
|
145
143
|
setNextPageToken(nextPage.nextPage?.token || null);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
declare const useFindCreationsAndLikes: ({ term, input, page
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { IDynamicAssetData, IQueryFindCreationsArgs } from "@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema";
|
|
3
|
+
declare const useFindCreationsAndLikes: ({ term, input, page }: IQueryFindCreationsArgs) => {
|
|
4
4
|
loading: boolean;
|
|
5
5
|
assetsLikesLoading: boolean;
|
|
6
6
|
creationsLoading: boolean;
|
|
7
7
|
error: import("@apollo/client").ApolloError | undefined;
|
|
8
|
-
creations:
|
|
8
|
+
creations: TCreation[];
|
|
9
9
|
results: number;
|
|
10
10
|
assetsLikes: [] | IDynamicAssetData[];
|
|
11
11
|
nextPageToken: string | null;
|
|
@@ -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.useFindCreationsAndLikes = void 0;
|
|
7
|
-
const
|
|
4
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
5
|
+
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
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 ui_1 = require("../../../store/ui");
|
|
14
|
-
const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
|
|
11
|
+
const react_1 = require("react");
|
|
15
12
|
const maxCreationLength = 1000;
|
|
16
|
-
const useFindCreationsAndLikes = ({ term, input, page
|
|
13
|
+
const useFindCreationsAndLikes = ({ term, input, page }) => {
|
|
17
14
|
const [creations, setCreations] = (0, react_1.useState)([]);
|
|
18
15
|
const [results, setResults] = (0, react_1.useState)(0);
|
|
19
16
|
const [nextPageToken, setNextPageToken] = (0, react_1.useState)(null);
|
|
@@ -26,12 +23,12 @@ const useFindCreationsAndLikes = ({ term, input, page, }) => {
|
|
|
26
23
|
input,
|
|
27
24
|
page,
|
|
28
25
|
},
|
|
29
|
-
fetchPolicy:
|
|
26
|
+
fetchPolicy: "no-cache",
|
|
30
27
|
context: {
|
|
31
28
|
uri: api_1.hosts.searchHost,
|
|
32
29
|
},
|
|
33
30
|
onCompleted: ({ findCreations: { creations, ...nextPage } }) => {
|
|
34
|
-
setCreations(creations.map((creation) =>
|
|
31
|
+
setCreations(creations.map((creation) => (0, builder_1.buildCreation)(creation)));
|
|
35
32
|
if (!creations.length) {
|
|
36
33
|
setLoading(false);
|
|
37
34
|
}
|
|
@@ -41,7 +38,7 @@ const useFindCreationsAndLikes = ({ term, input, page, }) => {
|
|
|
41
38
|
onError: () => {
|
|
42
39
|
openAlert({
|
|
43
40
|
type: type_1.alertVariants.error,
|
|
44
|
-
caption:
|
|
41
|
+
caption: "Oops, something went wrong.",
|
|
45
42
|
});
|
|
46
43
|
setCreations([]);
|
|
47
44
|
setNextPageToken(null);
|
|
@@ -53,7 +50,7 @@ const useFindCreationsAndLikes = ({ term, input, page, }) => {
|
|
|
53
50
|
context: {
|
|
54
51
|
uri: api_1.hosts.searchHost,
|
|
55
52
|
},
|
|
56
|
-
fetchPolicy:
|
|
53
|
+
fetchPolicy: "no-cache",
|
|
57
54
|
onCompleted: ({ fetchDynamicAssetsData }) => {
|
|
58
55
|
setAssetsLikes(fetchDynamicAssetsData);
|
|
59
56
|
setLoading(false);
|
|
@@ -61,7 +58,7 @@ const useFindCreationsAndLikes = ({ term, input, page, }) => {
|
|
|
61
58
|
onError: () => {
|
|
62
59
|
openAlert({
|
|
63
60
|
type: type_1.alertVariants.error,
|
|
64
|
-
caption:
|
|
61
|
+
caption: "Oops, something went wrong when fetch assets likes.",
|
|
65
62
|
});
|
|
66
63
|
setAssetsLikes([]);
|
|
67
64
|
setLoading(false);
|
|
@@ -105,7 +102,7 @@ const useFindCreationsAndLikes = ({ term, input, page, }) => {
|
|
|
105
102
|
input,
|
|
106
103
|
page: {
|
|
107
104
|
token: pageToken,
|
|
108
|
-
...(page &&
|
|
105
|
+
...(page && "size" in page ? { size: page.size } : {}),
|
|
109
106
|
},
|
|
110
107
|
},
|
|
111
108
|
updateQuery: (previousQueryResult) => {
|
|
@@ -115,7 +112,7 @@ const useFindCreationsAndLikes = ({ term, input, page, }) => {
|
|
|
115
112
|
const { creations: nextCreations, ...nextPage } = data.findCreations;
|
|
116
113
|
setCreations((prevCreations) => [
|
|
117
114
|
...prevCreations,
|
|
118
|
-
...nextCreations.map((creation) =>
|
|
115
|
+
...nextCreations.map((creation) => (0, builder_1.buildCreation)(creation)),
|
|
119
116
|
]);
|
|
120
117
|
setResults(nextPage.nextPage?.elements || 0);
|
|
121
118
|
setNextPageToken(nextPage.nextPage?.token || null);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
declare const useGetCollectionInfoAndLikes: ({ input
|
|
4
|
-
collectionAssetsList:
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { IDynamicAssetData, IQueryFetchDynamicCollectionDataArgs } from "@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema";
|
|
3
|
+
declare const useGetCollectionInfoAndLikes: ({ input }: IQueryFetchDynamicCollectionDataArgs) => {
|
|
4
|
+
collectionAssetsList: TCreation[];
|
|
5
5
|
collectionItemsLikes: [] | IDynamicAssetData[];
|
|
6
6
|
collectionLikes: number;
|
|
7
7
|
isCollectionLikedByUser: boolean;
|
|
@@ -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.useGetCollectionInfoAndLikes = void 0;
|
|
7
|
-
const
|
|
4
|
+
const collectionCreationBuilder_1 = require("../../../entities/creation/collectionCreationBuilder");
|
|
5
|
+
const useGetCreationsAndLikes_1 = require("./useGetCreationsAndLikes");
|
|
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 ui_1 = require("../../../store/ui");
|
|
14
|
-
const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
|
|
11
|
+
const react_1 = require("react");
|
|
15
12
|
const maxCollectionListLength = 1000;
|
|
16
|
-
const useGetCollectionInfoAndLikes = ({ input
|
|
13
|
+
const useGetCollectionInfoAndLikes = ({ input }) => {
|
|
17
14
|
const { page, collectionId } = input;
|
|
18
15
|
const openAlert = (0, ui_1.useUiStore)((state) => state.openAlert);
|
|
19
16
|
const [collectionAssetsList, setCollectionAssetsList] = (0, react_1.useState)([]);
|
|
@@ -32,7 +29,7 @@ const useGetCollectionInfoAndLikes = ({ input, }) => {
|
|
|
32
29
|
setCollectionLikes(likesNum);
|
|
33
30
|
setIsCollectionLikedByUser(isLikedByUser);
|
|
34
31
|
setNextPageToken(nextPage.token);
|
|
35
|
-
setCollectionAssetsList(collectionAssets.map((collectionAsset) =>
|
|
32
|
+
setCollectionAssetsList(collectionAssets.map((collectionAsset) => (0, collectionCreationBuilder_1.buildCollectionCreation)({
|
|
36
33
|
...collectionAsset,
|
|
37
34
|
collectionId: collectionAsset.assetId,
|
|
38
35
|
})));
|
|
@@ -41,7 +38,7 @@ const useGetCollectionInfoAndLikes = ({ input, }) => {
|
|
|
41
38
|
onError: () => {
|
|
42
39
|
openAlert({
|
|
43
40
|
type: type_1.alertVariants.error,
|
|
44
|
-
caption:
|
|
41
|
+
caption: "Oops, something went wrong.",
|
|
45
42
|
});
|
|
46
43
|
setCollectionAssetsList([]);
|
|
47
44
|
setNextPageToken(null);
|
|
@@ -73,8 +70,7 @@ const useGetCollectionInfoAndLikes = ({ input, }) => {
|
|
|
73
70
|
(0, react_1.useEffect)(() => {
|
|
74
71
|
if (!collectionLoading && collectionAssetsList.length > 0) {
|
|
75
72
|
const assetIds = (0, useGetCreationsAndLikes_1.extractItemIds)(collectionAssetsList);
|
|
76
|
-
if (assetIds.length > 0 &&
|
|
77
|
-
collectionAssetsList.length !== collectionItemsLikes.length) {
|
|
73
|
+
if (assetIds.length > 0 && collectionAssetsList.length !== collectionItemsLikes.length) {
|
|
78
74
|
setLoading(false);
|
|
79
75
|
{
|
|
80
76
|
/* Todo fix it by PR with new likes */
|
|
@@ -111,17 +107,14 @@ const useGetCollectionInfoAndLikes = ({ input, }) => {
|
|
|
111
107
|
input: { page: { token: pageToken, size: page?.size }, collectionId },
|
|
112
108
|
},
|
|
113
109
|
});
|
|
114
|
-
const { collectionAssetsPage: { nextPageToken, collectionAssets: nextCollectionAssetsList
|
|
115
|
-
const nextList = nextCollectionAssetsList.map((collectionAsset) =>
|
|
110
|
+
const { collectionAssetsPage: { nextPageToken, collectionAssets: nextCollectionAssetsList }, } = data.fetchDynamicCollectionData;
|
|
111
|
+
const nextList = nextCollectionAssetsList.map((collectionAsset) => (0, collectionCreationBuilder_1.buildCollectionCreation)({
|
|
116
112
|
...collectionAsset,
|
|
117
113
|
collectionId: collectionAsset.assetId,
|
|
118
114
|
}));
|
|
119
115
|
// const assetIds = getAssetIds(nextList);
|
|
120
116
|
// await fetchAssetsLikes({ variables: { assetIds } });
|
|
121
|
-
setCollectionAssetsList((prevCollection) => [
|
|
122
|
-
...prevCollection,
|
|
123
|
-
...nextList,
|
|
124
|
-
]);
|
|
117
|
+
setCollectionAssetsList((prevCollection) => [...prevCollection, ...nextList]);
|
|
125
118
|
setNextPageToken(nextPageToken);
|
|
126
119
|
}
|
|
127
120
|
catch (error) {
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import CreationEntity from '../../../dto/CreationEntity';
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { IDynamicAssetData, IDynamicCollectionData, IQueryFetchAllCreationsArgs } from "@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema";
|
|
4
3
|
declare const useGetCreationsAndLikes: ({ page }: IQueryFetchAllCreationsArgs) => {
|
|
5
4
|
loading: boolean;
|
|
6
5
|
assetsLikesLoading: boolean;
|
|
7
6
|
collectionsLikesLoading: boolean;
|
|
8
7
|
creationsLoading: boolean;
|
|
9
8
|
error: import("@apollo/client").ApolloError | undefined;
|
|
10
|
-
allCreations:
|
|
9
|
+
allCreations: TCreation[];
|
|
11
10
|
assetsLikes: [] | IDynamicAssetData[];
|
|
12
11
|
collectionsLikes: [] | IDynamicCollectionData[];
|
|
13
12
|
nextPageToken: string | null;
|
|
14
13
|
loadMore: (pageToken: string | null) => Promise<void>;
|
|
15
14
|
refetchQuery: () => Promise<void>;
|
|
16
15
|
};
|
|
17
|
-
declare function extractItemIds(creations:
|
|
16
|
+
declare function extractItemIds(creations: TCreation[]): string[];
|
|
18
17
|
export { useGetCreationsAndLikes, extractItemIds };
|
|
@@ -1,18 +1,15 @@
|
|
|
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.useGetCreationsAndLikes = void 0;
|
|
7
4
|
exports.extractItemIds = extractItemIds;
|
|
8
|
-
const
|
|
5
|
+
const builder_1 = require("../../../entities/creation/builder");
|
|
6
|
+
const types_1 = require("../../../entities/labelCreationType/types");
|
|
7
|
+
const ui_1 = require("../../../store/ui");
|
|
9
8
|
const client_1 = require("@apollo/client");
|
|
10
9
|
const api_1 = require("@ludo.ninja/api");
|
|
11
10
|
const schema_1 = require("@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema");
|
|
12
11
|
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"));
|
|
12
|
+
const react_1 = require("react");
|
|
16
13
|
const maxCreationLength = 1000;
|
|
17
14
|
const useGetCreationsAndLikes = ({ page }) => {
|
|
18
15
|
const [allCreations, setCreations] = (0, react_1.useState)([]);
|
|
@@ -29,7 +26,7 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
29
26
|
uri: api_1.hosts.searchHost,
|
|
30
27
|
},
|
|
31
28
|
onCompleted: ({ fetchAllCreations: { creations, ...nextPage } }) => {
|
|
32
|
-
setCreations(creations.map((creation) =>
|
|
29
|
+
setCreations(creations.map((creation) => (0, builder_1.buildCreation)(creation)));
|
|
33
30
|
setNextPageToken(nextPage.nextPage?.token || null);
|
|
34
31
|
},
|
|
35
32
|
onError: () => {
|
|
@@ -49,7 +46,7 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
49
46
|
onError: () => {
|
|
50
47
|
openAlert({
|
|
51
48
|
type: type_1.alertVariants.error,
|
|
52
|
-
caption:
|
|
49
|
+
caption: "Oops, something went wrong when fetch assets likes.",
|
|
53
50
|
});
|
|
54
51
|
setAssetsLikes([]);
|
|
55
52
|
setLoading(false);
|
|
@@ -64,7 +61,7 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
64
61
|
onError: () => {
|
|
65
62
|
openAlert({
|
|
66
63
|
type: type_1.alertVariants.error,
|
|
67
|
-
caption:
|
|
64
|
+
caption: "Oops, something went wrong when fetch collections likes.",
|
|
68
65
|
});
|
|
69
66
|
setCollectionsLikes([]);
|
|
70
67
|
setLoading(false);
|
|
@@ -74,10 +71,10 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
74
71
|
if (allCreations.length > 0) {
|
|
75
72
|
const itemsIdsArray = extractItemIds(allCreations);
|
|
76
73
|
if (itemsIdsArray.length > 0) {
|
|
77
|
-
if (allCreations[0].
|
|
74
|
+
if (allCreations[0].itemType === types_1.LabelKeys.asset) {
|
|
78
75
|
fetchAssetsLikes({ variables: { assetIds: itemsIdsArray } });
|
|
79
76
|
}
|
|
80
|
-
else if (allCreations[0].
|
|
77
|
+
else if (allCreations[0].itemType === types_1.LabelKeys.collection) {
|
|
81
78
|
fetchCollectionsLikes({
|
|
82
79
|
variables: {
|
|
83
80
|
input: itemsIdsArray.map((collectionId) => {
|
|
@@ -115,14 +112,14 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
115
112
|
variables: {
|
|
116
113
|
page: {
|
|
117
114
|
token: pageToken,
|
|
118
|
-
...(page &&
|
|
115
|
+
...(page && "size" in page ? { size: page.size } : {}),
|
|
119
116
|
},
|
|
120
117
|
},
|
|
121
118
|
});
|
|
122
119
|
const { creations: nextCreations, ...nextPage } = data.fetchAllCreations;
|
|
123
120
|
setCreations((prevCreations) => [
|
|
124
121
|
...prevCreations,
|
|
125
|
-
...nextCreations.map((creation) =>
|
|
122
|
+
...nextCreations.map((creation) => (0, builder_1.buildCreation)(creation)),
|
|
126
123
|
]);
|
|
127
124
|
setNextPageToken(nextPage.nextPage?.token || null);
|
|
128
125
|
}
|
|
@@ -133,7 +130,5 @@ const useGetCreationsAndLikes = ({ page }) => {
|
|
|
133
130
|
};
|
|
134
131
|
exports.useGetCreationsAndLikes = useGetCreationsAndLikes;
|
|
135
132
|
function extractItemIds(creations) {
|
|
136
|
-
return creations.map((creation) => creation
|
|
137
|
-
? creation.getCreationId()
|
|
138
|
-
: creation.getItemId());
|
|
133
|
+
return creations.map((creation) => creation.itemId);
|
|
139
134
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
declare const useGetCreationsAndLikesByType: ({ itemType, page
|
|
1
|
+
import { TCreation } from '../../../entities/creation/types';
|
|
2
|
+
import { IDynamicAssetData, IDynamicCollectionData, IQueryFetchCreationsByTypeArgs } from "@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema";
|
|
3
|
+
declare const useGetCreationsAndLikesByType: ({ itemType, page }: IQueryFetchCreationsByTypeArgs) => {
|
|
4
4
|
loading: boolean;
|
|
5
5
|
assetsLikesLoading: boolean;
|
|
6
6
|
collectionsLikesLoading: boolean;
|
|
7
7
|
creationsLoading: boolean;
|
|
8
8
|
error: import("@apollo/client").ApolloError | undefined;
|
|
9
|
-
allCreations:
|
|
9
|
+
allCreations: TCreation[];
|
|
10
10
|
assetsLikes: [] | IDynamicAssetData[];
|
|
11
11
|
collectionsLikes: [] | IDynamicCollectionData[];
|
|
12
12
|
nextPageToken: string | null;
|