@ludo.ninja/components 2.2.36 → 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.
Files changed (56) hide show
  1. package/build/api/server-galleries/queries/useFetchGallery/index.d.ts +5 -5
  2. package/build/api/server-galleries/queries/useFetchGallery/index.js +5 -8
  3. package/build/api/server-galleries/queries/useFetchMyFavorites/index.d.ts +3 -3
  4. package/build/api/server-galleries/queries/useFetchMyFavorites/index.js +5 -11
  5. package/build/api/server-galleries/queries/useFetchMyGalleries/index.d.ts +3 -3
  6. package/build/api/server-galleries/queries/useFetchMyGalleries/index.js +5 -11
  7. package/build/api/server-galleries/queries/useFetchUserFavorites/index.d.ts +4 -4
  8. package/build/api/server-galleries/queries/useFetchUserFavorites/index.js +6 -9
  9. package/build/components/assetPage/assetLikes/index.js +7 -7
  10. package/build/components/search/searchSuggestions/index.js +2 -2
  11. package/build/dto/AssetEntity/index.d.ts +3 -3
  12. package/build/dto/AssetEntity/index.js +16 -33
  13. package/build/dto/AssetSearchEntity/index.d.ts +2 -2
  14. package/build/dto/AssetSearchEntity/index.js +12 -29
  15. package/build/dto/Collection/CollectionCreationEntity/index.d.ts +3 -3
  16. package/build/dto/Collection/CollectionCreationEntity/index.js +13 -13
  17. package/build/dto/Collection/CollectionCreationEntity/interface.d.ts +2 -2
  18. package/build/dto/Collection/CollectionEntity/index.d.ts +2 -2
  19. package/build/dto/Collection/CollectionEntity/index.js +1 -1
  20. package/build/dto/CreationEntity/index.d.ts +3 -3
  21. package/build/dto/CreationEntity/index.js +9 -9
  22. package/build/dto/GalleryEntityV2/index.d.ts +4 -4
  23. package/build/dto/GalleryEntityV2/index.js +6 -8
  24. package/build/dto/common/ItemType/data.d.ts +1 -1
  25. package/build/dto/common/ItemType/data.js +25 -25
  26. package/build/entities/gallery/builder.js +1 -1
  27. package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.d.ts +4 -4
  28. package/build/hooks/favorites/useGetFavoriteGallaryCreations/index.js +17 -19
  29. package/build/hooks/favorites/useGetUserFevoritesCreations/index.d.ts +5 -5
  30. package/build/hooks/favorites/useGetUserFevoritesCreations/index.js +23 -33
  31. package/build/hooks/galleries/useGetUserGalleriesCreations/index.d.ts +5 -5
  32. package/build/hooks/galleries/useGetUserGalleriesCreations/index.js +23 -33
  33. package/build/hooks/likes/dynamic/useGetMixedLikesFavoriteList.d.ts +1 -1
  34. package/build/hooks/likes/index.d.ts +1 -1
  35. package/build/hooks/likes/index.js +12 -12
  36. package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.d.ts +4 -4
  37. package/build/modules/gallery/api/useGetAssetsAndCollectionForFavorite.js +35 -40
  38. package/build/modules/gallery/store.d.ts +3 -3
  39. package/build/modules/gallery/store.js +7 -11
  40. package/build/modules/gallery/ui/EditGallery.d.ts +2 -2
  41. package/build/modules/gallery/ui/EditGallery.js +11 -11
  42. package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.d.ts +3 -3
  43. package/build/modules/gallery/ui/chooseGalleryItems/chooseGalleryItem/index.js +1 -1
  44. package/build/modules/gallery/ui/chooseGalleryItems/index.d.ts +1 -1
  45. package/build/modules/gallery/ui/chooseGalleryItems/index.js +19 -20
  46. package/build/modules/opportunity/OpportunityCard.js +25 -27
  47. package/build/system/Cards/CardContent/CardCategory/CardCategory.test.d.ts +1 -1
  48. package/build/system/Cards/CardContent/CardCategory/CardCategory.test.js +9 -9
  49. package/build/system/Cards/CardContent/CardCategory/index.d.ts +1 -1
  50. package/build/system/Cards/CardContent/CardCategory/index.js +3 -3
  51. package/build/system/Cards/CreationCard/CardHead.js +16 -21
  52. package/build/system/Cards/CreationCard/index.d.ts +2 -2
  53. package/build/system/Cards/CreationCard/index.js +5 -5
  54. package/build/system/Cards/MultiMediaCard/index.d.ts +2 -2
  55. package/build/system/Cards/MultiMediaCard/index.js +3 -3
  56. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { collectionsSchema } from '@ludo.ninja/api';
2
- import { BlockChainEntity, MarketPlaceEntity, ProfileEntity } from '@ludo.ninja/core';
3
1
  import ICollectionEntity from './interface';
2
+ import { collectionsSchema } from "@ludo.ninja/api";
3
+ import { BlockChainEntity, MarketPlaceEntity, ProfileEntity } from "@ludo.ninja/core";
4
4
  declare class CollectionEntity implements ICollectionEntity {
5
5
  private collectionTitle;
6
6
  private collectionId;
@@ -34,7 +34,7 @@ class CollectionEntity {
34
34
  this.liked = collection.liked;
35
35
  }
36
36
  getCollectionId() {
37
- return this.collectionId ? this.collectionId : 'no id';
37
+ return this.collectionId ? this.collectionId : "no id";
38
38
  }
39
39
  getBlockchain() {
40
40
  return this.blockchain;
@@ -1,8 +1,8 @@
1
- import { searchSchema as schema } from '@ludo.ninja/api';
2
- import { BlockChainEntity } from '@ludo.ninja/core';
3
1
  import ICreationEntity from './interface';
4
- import { LabelKeys, LabelType } from '../common/ItemType';
5
2
  import Media from '../common/Media';
3
+ import { LabelKeys, LabelType } from '../../entities/labelCreationType/types';
4
+ import { searchSchema as schema } from "@ludo.ninja/api";
5
+ import { BlockChainEntity } from "@ludo.ninja/core";
6
6
  declare class CreationEntity implements ICreationEntity {
7
7
  private itemId;
8
8
  private itemType;
@@ -3,14 +3,14 @@ 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 core_1 = require("@ludo.ninja/core");
7
- const ItemType_1 = require("../common/ItemType");
8
- const data_1 = __importDefault(require("../common/ItemType/data"));
9
6
  const CreationAudio_1 = __importDefault(require("../common/ItemViews/CreationAudio"));
10
7
  const CreationImage_1 = __importDefault(require("../common/ItemViews/CreationImage"));
11
8
  const CreationObject_1 = __importDefault(require("../common/ItemViews/CreationObject"));
12
9
  const CreationOther_1 = __importDefault(require("../common/ItemViews/CreationOther"));
13
10
  const CreationVideo_1 = __importDefault(require("../common/ItemViews/CreationVideo"));
11
+ const types_1 = require("../../entities/labelCreationType/types");
12
+ const data_1 = __importDefault(require("../../entities/labelCreationType/data"));
13
+ const core_1 = require("@ludo.ninja/core");
14
14
  class CreationEntity {
15
15
  itemId;
16
16
  itemType;
@@ -57,13 +57,13 @@ class CreationEntity {
57
57
  }
58
58
  // accessors
59
59
  getAddress() {
60
- return this.address ? this.address : '';
60
+ return this.address ? this.address : "";
61
61
  }
62
62
  getId() {
63
- return this.id ? this.id : '';
63
+ return this.id ? this.id : "";
64
64
  }
65
65
  getTokenId() {
66
- return this.tokenId ? this.tokenId : '';
66
+ return this.tokenId ? this.tokenId : "";
67
67
  }
68
68
  getItemId() {
69
69
  return this.itemId;
@@ -87,7 +87,7 @@ class CreationEntity {
87
87
  return this.isCheckboxSelected;
88
88
  }
89
89
  getCreationLink() {
90
- if (this.getItemType() === ItemType_1.LabelKeys.asset) {
90
+ if (this.getItemType() === types_1.LabelKeys.asset) {
91
91
  const blockChainPrivateLabel = this.getBlockchain().getBlockChainPrivateLabel();
92
92
  if (blockChainPrivateLabel === core_1.BlockChainKeys.elrond) {
93
93
  return `/${this.getItemType()}/${this.getBlockchain().getBlockChainPrivateLabel()}/${this.getId()}`;
@@ -144,10 +144,10 @@ class CreationEntity {
144
144
  return null;
145
145
  return isMobileView
146
146
  ? this.name && this.name.length >= 20
147
- ? this.name?.substring(0, 22).concat('...')
147
+ ? this.name?.substring(0, 22).concat("...")
148
148
  : this.name
149
149
  : this.name && this.name.length >= 11
150
- ? this.name?.substring(0, 13).concat('...')
150
+ ? this.name?.substring(0, 13).concat("...")
151
151
  : this.name;
152
152
  }
153
153
  // methods
@@ -1,7 +1,7 @@
1
- import { galleriesSchema as schema } from '@ludo.ninja/api';
2
- import { ProfileEntity } from '@ludo.ninja/core';
3
- import { LabelKeys, LabelType } from '../common/ItemType';
4
- import IGalleryEntityV2 from './interface';
1
+ import { LabelKeys, LabelType } from "../common/ItemType";
2
+ import IGalleryEntityV2 from "./interface";
3
+ import { galleriesSchema as schema } from "@ludo.ninja/api";
4
+ import { ProfileEntity } from "@ludo.ninja/core";
5
5
  declare class GalleryEntityV2 implements IGalleryEntityV2 {
6
6
  private galleryId;
7
7
  private galleryType;
@@ -3,8 +3,8 @@ 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 data_1 = __importDefault(require("../../entities/labelCreationType/data"));
6
7
  const core_1 = require("@ludo.ninja/core");
7
- const data_1 = __importDefault(require("../common/ItemType/data"));
8
8
  class GalleryEntityV2 {
9
9
  galleryId;
10
10
  galleryType;
@@ -45,10 +45,10 @@ class GalleryEntityV2 {
45
45
  return this.galleryId;
46
46
  }
47
47
  getGalleryUsername() {
48
- return this.username ?? '';
48
+ return this.username ?? "";
49
49
  }
50
50
  getGalleryUserpic() {
51
- return this.userpic ?? '';
51
+ return this.userpic ?? "";
52
52
  }
53
53
  getGalleryUserWallets() {
54
54
  return this.userWallets;
@@ -57,15 +57,13 @@ class GalleryEntityV2 {
57
57
  return this.name;
58
58
  }
59
59
  getGalleryItemsCount() {
60
- return this.items
61
- ? `${this?.items > 1 ? `${this?.items} items` : `${this?.items} item`}`
62
- : '0 items';
60
+ return this.items ? `${this?.items > 1 ? `${this?.items} items` : `${this?.items} item`}` : "0 items";
63
61
  }
64
62
  getGalleryCreationIds() {
65
63
  return this.creationIds ? this.creationIds : [];
66
64
  }
67
65
  getGalleryDescription() {
68
- return this.description ? this.description : '';
66
+ return this.description ? this.description : "";
69
67
  }
70
68
  getGalleryType() {
71
69
  return this.galleryType;
@@ -74,7 +72,7 @@ class GalleryEntityV2 {
74
72
  return data_1.default[this.getGalleryType()];
75
73
  }
76
74
  getCreationLink() {
77
- return this.getGalleryType() === 'likelist'
75
+ return this.getGalleryType() === "likelist"
78
76
  ? `/favorites/${this.getGalleryId()}`
79
77
  : `/${this.getGalleryType()}/${this.getGalleryId()}`;
80
78
  }
@@ -1,3 +1,3 @@
1
- import { LabelItem } from './';
1
+ import { LabelItem } from '../../../entities/labelCreationType/types';
2
2
  declare const labelsData: LabelItem;
3
3
  export default labelsData;
@@ -1,36 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const ItemType_1 = require("./");
3
+ const types_1 = require("../../../entities/labelCreationType/types");
4
4
  const labelsData = {
5
- [ItemType_1.LabelKeys.asset]: {
6
- backgroundColor: ItemType_1.LabelBackground.asset,
7
- color: ItemType_1.LabelColor.asset,
8
- text: ItemType_1.LabelText.asset,
5
+ [types_1.LabelKeys.asset]: {
6
+ backgroundColor: types_1.LabelBackground.asset,
7
+ color: types_1.LabelColor.asset,
8
+ text: types_1.LabelText.asset,
9
9
  },
10
- [ItemType_1.LabelKeys.collection]: {
11
- backgroundColor: ItemType_1.LabelBackground.collection,
12
- color: ItemType_1.LabelColor.collection,
13
- text: ItemType_1.LabelText.collection,
10
+ [types_1.LabelKeys.collection]: {
11
+ backgroundColor: types_1.LabelBackground.collection,
12
+ color: types_1.LabelColor.collection,
13
+ text: types_1.LabelText.collection,
14
14
  },
15
- [ItemType_1.LabelKeys.gallery]: {
16
- backgroundColor: ItemType_1.LabelBackground.gallery,
17
- color: ItemType_1.LabelColor.gallery,
18
- text: ItemType_1.LabelText.gallery,
15
+ [types_1.LabelKeys.gallery]: {
16
+ backgroundColor: types_1.LabelBackground.gallery,
17
+ color: types_1.LabelColor.gallery,
18
+ text: types_1.LabelText.gallery,
19
19
  },
20
- [ItemType_1.LabelKeys.favorites]: {
21
- backgroundColor: ItemType_1.LabelBackground.favorites,
22
- color: ItemType_1.LabelColor.favorites,
23
- text: ItemType_1.LabelText.favorites,
20
+ [types_1.LabelKeys.favorites]: {
21
+ backgroundColor: types_1.LabelBackground.favorites,
22
+ color: types_1.LabelColor.favorites,
23
+ text: types_1.LabelText.favorites,
24
24
  },
25
- [ItemType_1.LabelKeys.likelist]: {
26
- backgroundColor: ItemType_1.LabelBackground.likelist,
27
- color: ItemType_1.LabelColor.likelist,
28
- text: ItemType_1.LabelText.likelist,
25
+ [types_1.LabelKeys.likelist]: {
26
+ backgroundColor: types_1.LabelBackground.likelist,
27
+ color: types_1.LabelColor.likelist,
28
+ text: types_1.LabelText.likelist,
29
29
  },
30
- [ItemType_1.LabelKeys.opportunity]: {
31
- backgroundColor: ItemType_1.LabelBackground.opportunity,
32
- color: ItemType_1.LabelColor.opportunity,
33
- text: ItemType_1.LabelText.opportunity,
30
+ [types_1.LabelKeys.opportunity]: {
31
+ backgroundColor: types_1.LabelBackground.opportunity,
32
+ color: types_1.LabelColor.opportunity,
33
+ text: types_1.LabelText.opportunity,
34
34
  },
35
35
  };
36
36
  exports.default = labelsData;
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.buildGallery = void 0;
7
- const data_1 = __importDefault(require("../../dto/common/ItemType/data"));
7
+ const data_1 = __importDefault(require("../labelCreationType/data"));
8
8
  const core_1 = require("@ludo.ninja/core");
9
9
  const buildGallery = (gallery) => {
10
10
  const newGallery = {
@@ -1,12 +1,12 @@
1
- import { IQueryFetchGalleryV2Args } 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 GalleryEntityV2 from '../../../dto/GalleryEntityV2';
3
+ import { TGallery } from '../../../entities/gallery/types';
4
+ import { IQueryFetchGalleryV2Args } from "@ludo.ninja/api/build/graphql_tools/__generated__/galleriesHost/schema";
5
5
  declare const useGetFavoriteGallaryCreations: ({ galleryId, itemsCount, }: {
6
6
  galleryId: string;
7
7
  itemsCount: number | null;
8
8
  }) => {
9
- gallery: GalleryEntityV2[] | null;
9
+ gallery: TGallery[] | null;
10
10
  loading: boolean;
11
11
  creationsList: (CreationEntity | CollectionCreationEntity)[];
12
12
  loadingAssets: boolean;
@@ -17,7 +17,7 @@ declare const useGetFavoriteGallaryCreations: ({ galleryId, itemsCount, }: {
17
17
  errorGallery: import("@apollo/client").ApolloError | undefined;
18
18
  fetchError: boolean;
19
19
  allResults: number | null;
20
- refetchQueryGalleryCreation: ({ galleryId, }: IQueryFetchGalleryV2Args) => Promise<void>;
20
+ refetchQueryGalleryCreation: ({ galleryId }: IQueryFetchGalleryV2Args) => Promise<void>;
21
21
  loadMore: () => void;
22
22
  };
23
23
  export { useGetFavoriteGallaryCreations };
@@ -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 react_1 = require("react");
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 ui_1 = require("../../../store/ui");
14
- const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
15
- const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
16
- const GalleryEntityV2_1 = __importDefault(require("../../../dto/GalleryEntityV2"));
17
- const useGetUserFevoritesCreations_1 = require("../useGetUserFevoritesCreations");
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: 'no-cache',
33
+ fetchPolicy: "no-cache",
34
34
  onCompleted: ({ fetchGalleryV2 }) => {
35
- setGallery([new GalleryEntityV2_1.default(fetchGalleryV2)]);
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: 'no-cache',
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: 'asset',
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: 'Oops, something went wrong.',
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 },] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
67
+ const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
68
68
  context: { uri: api_1.hosts.searchHost },
69
- fetchPolicy: 'no-cache',
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, '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: 'Oops, something went wrong.',
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 GalleryEntityV2 from '../../../dto/GalleryEntityV2';
5
- declare const useGetUserFevoritesCreations: ({ userId, pageSize, pageToken, }: IQueryFetchUserFavoritesV2Args) => {
6
- favorites: GalleryEntityV2[];
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: GalleryEntityV2[], takeFirstFour: boolean, pageNumber?: number, totalLength?: number | null): {
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 react_1 = require("react");
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 ui_1 = require("../../../store/ui");
15
- const CollectionCreationEntity_1 = __importDefault(require("../../../dto/Collection/CollectionCreationEntity"));
16
- const CreationEntity_1 = __importDefault(require("../../../dto/CreationEntity"));
17
- const GalleryEntityV2_1 = __importDefault(require("../../../dto/GalleryEntityV2"));
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: 'no-cache',
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) => new GalleryEntityV2_1.default(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: 'Oops, something went wrong while fetching favorites.',
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: 'no-cache',
50
+ fetchPolicy: "no-cache",
51
51
  onCompleted: ({ fetchAssets: data }) => {
52
52
  setAsset(data.map((asset) => new CreationEntity_1.default({
53
53
  ...asset,
54
- itemType: 'asset',
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: 'Oops, something went wrong.',
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 },] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
68
+ const [fetchCollections, { loading: collectionsLoading, error: collectionsError }] = (0, client_1.useLazyQuery)(schema_2.FetchCollectionsByIdsDocument, {
69
69
  context: { uri: api_1.hosts.searchHost },
70
- fetchPolicy: 'no-cache',
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: 'Oops, something went wrong.',
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('fetchMyFavoritesV2')) {
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('.')[0] === 'asset') {
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('.')[0] === 'collection') {
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 GalleryEntityV2 from '../../../dto/GalleryEntityV2';
5
- declare const useGetUserGalleriesCreations: ({ userId, pageSize, pageToken, }: IQueryFetchUserGalleriesV2Args) => {
6
- galleries: GalleryEntityV2[];
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: GalleryEntityV2[], takeFirstFour: boolean): {
21
+ export declare function getMediaForGallery(favorites: TGallery[], takeFirstFour: boolean): {
22
22
  assetArray: unknown[];
23
23
  collectionsArray: unknown[];
24
24
  };