@ludo.ninja/components 1.5.9 → 1.6.1
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/dist/hooks/apollo/index.d.ts +2 -1
- package/dist/hooks/apollo/index.jsx +7 -1
- package/dist/hooks/searchFiltersConnector/index.d.ts +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/api/graphql/index.d.ts +0 -4
- package/dist/api/graphql/index.js +0 -7
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/server-assets/mutations/useDislikeAsset/index.d.ts +0 -7
- package/dist/api/server-assets/mutations/useDislikeAsset/index.js +0 -79
- package/dist/api/server-assets/mutations/useLikeAsset/index.d.ts +0 -7
- package/dist/api/server-assets/mutations/useLikeAsset/index.js +0 -80
- package/dist/api/server-assets/queries/useFetchAssetByBlockchain/index.d.ts +0 -14
- package/dist/api/server-assets/queries/useFetchAssetByBlockchain/index.js +0 -84
- package/dist/api/server-assets/queries/useFetchAssets/index.d.ts +0 -7
- package/dist/api/server-assets/queries/useFetchAssets/index.js +0 -30
- package/dist/api/server-assets/queries/useFetchDynamicAssetLikes/index.d.ts +0 -8
- package/dist/api/server-assets/queries/useFetchDynamicAssetLikes/index.js +0 -35
- package/dist/api/server-assets/queries/useFetchDynamicAssetsLikes/index.d.ts +0 -7
- package/dist/api/server-assets/queries/useFetchDynamicAssetsLikes/index.js +0 -30
- package/dist/api/server-collection/mutations/useDislikeCollection/index.d.ts +0 -7
- package/dist/api/server-collection/mutations/useDislikeCollection/index.js +0 -78
- package/dist/api/server-collection/mutations/useLikeCollection/index.d.ts +0 -7
- package/dist/api/server-collection/mutations/useLikeCollection/index.js +0 -78
- package/dist/api/server-experiences/queries/useFetchMyExperienceWithLevel/index.d.ts +0 -2
- package/dist/api/server-experiences/queries/useFetchMyExperienceWithLevel/index.js +0 -91
- package/dist/api/server-experiences/queries/useFetchMyTasks/index.d.ts +0 -31
- package/dist/api/server-experiences/queries/useFetchMyTasks/index.js +0 -46
- package/dist/api/server-galleries/mutations/useAddAssetsToGallery/index.d.ts +0 -7
- package/dist/api/server-galleries/mutations/useAddAssetsToGallery/index.js +0 -82
- package/dist/api/server-galleries/mutations/useAddChangeGalleryBanner/index.d.ts +0 -4
- package/dist/api/server-galleries/mutations/useAddChangeGalleryBanner/index.js +0 -67
- package/dist/api/server-galleries/mutations/useAddCollectionsToGallery/index.d.ts +0 -7
- package/dist/api/server-galleries/mutations/useAddCollectionsToGallery/index.js +0 -81
- package/dist/api/server-galleries/mutations/useAddCreationsToGallery/index.d.ts +0 -7
- package/dist/api/server-galleries/mutations/useAddCreationsToGallery/index.js +0 -89
- package/dist/api/server-galleries/mutations/useCreateFavorites/index.d.ts +0 -6
- package/dist/api/server-galleries/mutations/useCreateFavorites/index.js +0 -70
- package/dist/api/server-galleries/mutations/useCreateGallery/index.d.ts +0 -6
- package/dist/api/server-galleries/mutations/useCreateGallery/index.js +0 -70
- package/dist/api/server-galleries/mutations/useDeleteGallery/index.d.ts +0 -8
- package/dist/api/server-galleries/mutations/useDeleteGallery/index.js +0 -87
- package/dist/api/server-galleries/mutations/useDeleteGalleryBanner/index.d.ts +0 -5
- package/dist/api/server-galleries/mutations/useDeleteGalleryBanner/index.js +0 -83
- package/dist/api/server-galleries/mutations/useEditGallery/index.d.ts +0 -5
- package/dist/api/server-galleries/mutations/useEditGallery/index.js +0 -62
- package/dist/api/server-galleries/mutations/useRemoveAssetFromGallery/index.d.ts +0 -7
- package/dist/api/server-galleries/mutations/useRemoveAssetFromGallery/index.js +0 -95
- package/dist/api/server-galleries/mutations/useRemoveCollectionFromGallery/index.d.ts +0 -7
- package/dist/api/server-galleries/mutations/useRemoveCollectionFromGallery/index.js +0 -90
- package/dist/api/server-galleries/queries/useFetchGallery/index.d.ts +0 -16
- package/dist/api/server-galleries/queries/useFetchGallery/index.js +0 -42
- package/dist/api/server-galleries/queries/useFetchGalleryAssets/index.d.ts +0 -18
- package/dist/api/server-galleries/queries/useFetchGalleryAssets/index.js +0 -115
- package/dist/api/server-galleries/queries/useFetchMyFavorites/index.d.ts +0 -10
- package/dist/api/server-galleries/queries/useFetchMyFavorites/index.js +0 -120
- package/dist/api/server-galleries/queries/useFetchMyGalleries/index.d.ts +0 -10
- package/dist/api/server-galleries/queries/useFetchMyGalleries/index.js +0 -123
- package/dist/api/server-galleries/queries/useFetchSubscribedGalleries/index.d.ts +0 -9
- package/dist/api/server-galleries/queries/useFetchSubscribedGalleries/index.js +0 -95
- package/dist/api/server-galleries/queries/useFetchUserFavorites/index.d.ts +0 -11
- package/dist/api/server-galleries/queries/useFetchUserFavorites/index.js +0 -130
- package/dist/api/server-identities/mutations/useAddWalletElrond/index.d.ts +0 -6
- package/dist/api/server-identities/mutations/useAddWalletElrond/index.js +0 -37
- package/dist/api/server-identities/mutations/useAddWalletFlow/index.d.ts +0 -5
- package/dist/api/server-identities/mutations/useAddWalletFlow/index.js +0 -78
- package/dist/api/server-identities/mutations/useAddWalletMetamask/index.d.ts +0 -12
- package/dist/api/server-identities/mutations/useAddWalletMetamask/index.js +0 -87
- package/dist/api/server-identities/mutations/useAddWalletSolana/index.d.ts +0 -5
- package/dist/api/server-identities/mutations/useAddWalletSolana/index.js +0 -82
- package/dist/api/server-identities/mutations/useAddWalletTezos/index.d.ts +0 -5
- package/dist/api/server-identities/mutations/useAddWalletTezos/index.js +0 -78
- package/dist/api/server-identities/mutations/useFollowProfile/index.d.ts +0 -7
- package/dist/api/server-identities/mutations/useFollowProfile/index.js +0 -40
- package/dist/api/server-identities/mutations/useGenerateNewInviteCodes/index.d.ts +0 -7
- package/dist/api/server-identities/mutations/useGenerateNewInviteCodes/index.js +0 -78
- package/dist/api/server-identities/mutations/useInviteCode/index.d.ts +0 -9
- package/dist/api/server-identities/mutations/useInviteCode/index.js +0 -76
- package/dist/api/server-identities/mutations/useRemoveWallet/index.d.ts +0 -8
- package/dist/api/server-identities/mutations/useRemoveWallet/index.js +0 -44
- package/dist/api/server-identities/mutations/useRevokeToken/index.d.ts +0 -4
- package/dist/api/server-identities/mutations/useRevokeToken/index.js +0 -66
- package/dist/api/server-identities/mutations/useSaveEmailOfJoiner/index.js +0 -76
- package/dist/api/server-identities/mutations/useUnfollowProfile/index.d.ts +0 -7
- package/dist/api/server-identities/mutations/useUnfollowProfile/index.js +0 -39
- package/dist/api/server-identities/queries/useFetchProfile/index.d.ts +0 -16
- package/dist/api/server-identities/queries/useFetchProfile/index.js +0 -79
- package/dist/api/server-identities/queries/useFetchUserWallets/index.js +0 -19
- package/dist/api/server-identities/queries/useGetMyInviteCodes/index.d.ts +0 -8
- package/dist/api/server-identities/queries/useGetMyInviteCodes/index.js +0 -36
- package/dist/api/server-medias/mutations/useDeleteUserpic/index.d.ts +0 -6
- package/dist/api/server-medias/mutations/useDeleteUserpic/index.js +0 -19
- package/dist/api/server-medias/mutations/useUploadUserpic/index.d.ts +0 -4
- package/dist/api/server-medias/mutations/useUploadUserpic/index.js +0 -69
- package/dist/api/server-medias/queries/useFetchUserPic/index.js +0 -37
- package/dist/api/server-opportunities/mutations/useDislikeOpportunity.d.ts +0 -4
- package/dist/api/server-opportunities/mutations/useDislikeOpportunity.js +0 -71
- package/dist/api/server-opportunities/mutations/useLikeOpportunity.d.ts +0 -4
- package/dist/api/server-opportunities/mutations/useLikeOpportunity.js +0 -71
- package/dist/api/server-opportunities/mutations/useOpenOpportunity/index.d.ts +0 -5
- package/dist/api/server-opportunities/mutations/useOpenOpportunity/index.js +0 -72
- package/dist/api/server-opportunities/queries/useGetOpportunities.d.ts +0 -4
- package/dist/api/server-opportunities/queries/useGetOpportunities.js +0 -22
- package/dist/api/server-preferences/mutations/useSaveUserExpectations/index.d.ts +0 -4
- package/dist/api/server-preferences/mutations/useSaveUserExpectations/index.jsx +0 -86
- package/dist/api/server-preferences/mutations/useSaveUserInterests/index.d.ts +0 -4
- package/dist/api/server-preferences/mutations/useSaveUserInterests/index.js +0 -86
- package/dist/api/server-preferences/queries/fetchSearchResultSelections/index.js +0 -28
- package/dist/api/server-preferences/queries/fetchSearchResultSelections/queryData.d.ts +0 -14
- package/dist/api/server-preferences/queries/fetchSearchResultSelections/queryData.js +0 -87
- package/dist/api/server-preferences/queries/useFetchExpectations/index.js +0 -19
- package/dist/api/server-preferences/queries/useFetchInterests/index.js +0 -19
- package/dist/api/server-preferences/queries/useFetchSearchResultTimeSelection/index.d.ts +0 -12
- package/dist/api/server-preferences/queries/useFetchSearchResultTimeSelection/index.js +0 -36
- package/dist/api/server-preferences/queries/useFetchUserInterests/index.d.ts +0 -7
- package/dist/api/server-preferences/queries/useFetchUserInterests/index.js +0 -20
- package/dist/api/server-preferences/queries/useSearchResultBlockchainSelections/index.d.ts +0 -13
- package/dist/api/server-preferences/queries/useSearchResultBlockchainSelections/index.js +0 -37
- package/dist/api/server-preferences/queries/useSearchResultCategorySelections/index.d.ts +0 -13
- package/dist/api/server-preferences/queries/useSearchResultCategorySelections/index.js +0 -37
- package/dist/api/server-preferences/queries/useSearchResultStatusSelections/index.d.ts +0 -14
- package/dist/api/server-preferences/queries/useSearchResultStatusSelections/index.js +0 -38
- package/dist/api/server-preferences/queries/useSearchResultTypeSelections/index.d.ts +0 -13
- package/dist/api/server-preferences/queries/useSearchResultTypeSelections/index.js +0 -42
- package/dist/api/server-search/queries/useFetchAllCreations/index.js +0 -171
- package/dist/api/server-search/queries/useFetchAssetsCount/index.d.ts +0 -7
- package/dist/api/server-search/queries/useFetchAssetsCount/index.js +0 -31
- package/dist/api/server-search/queries/useFetchCollection/index.d.ts +0 -19
- package/dist/api/server-search/queries/useFetchCollection/index.js +0 -55
- package/dist/api/server-search/queries/useFetchCollections/index.d.ts +0 -23
- package/dist/api/server-search/queries/useFetchCollections/index.js +0 -176
- package/dist/api/server-search/queries/useFetchDynamicCollectionData/index.d.ts +0 -13
- package/dist/api/server-search/queries/useFetchDynamicCollectionData/index.js +0 -195
- package/dist/api/server-search/queries/useFetchFindAllTopEntitiesByName/index.js +0 -54
- package/dist/api/server-search/queries/useFetchNetWorth/index.d.ts +0 -7
- package/dist/api/server-search/queries/useFetchNetWorth/index.js +0 -22
- package/dist/api/server-search/queries/useFindCreations/index.js +0 -184
- package/dist/api/server-search/queries/useFindProfilesByName/index.js +0 -58
- package/dist/api/server-search/queries/useFindShowcaseItems/index.d.ts +0 -2
- package/dist/api/server-search/queries/useFindShowcaseItems/index.js +0 -40
- package/dist/api/server-search/queries/useFindUserCreations/index.js +0 -168
- package/dist/api/server-search/queries/useFindUserShowcaseItems/index.d.ts +0 -2
- package/dist/api/server-search/queries/useFindUserShowcaseItems/index.js +0 -38
- package/dist/api/subscriptions/SubscriberInviteNotification.d.ts +0 -2
- package/dist/api/subscriptions/SubscriberInviteNotification.jsx +0 -40
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
-
var t = {};
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
|
-
if (ar || !(i in from)) {
|
|
62
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
63
|
-
ar[i] = from[i];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
|
-
};
|
|
68
|
-
import { useState } from 'react';
|
|
69
|
-
import { useQuery } from '@apollo/client';
|
|
70
|
-
import { hosts, searchSchema as schema } from '@ludo.ninja/api';
|
|
71
|
-
import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
|
|
72
|
-
import { useUiStore } from '@/store/ui';
|
|
73
|
-
import CollectionCreationEntity from '@/dto/Collection/CollectionCreationEntity';
|
|
74
|
-
// export const prefetchFindCollections = (
|
|
75
|
-
// { term, input, pageSize, pageToken }: schema.IQueryFindCollectionsArgs,
|
|
76
|
-
// apolloClient: ApolloClient<NormalizedCacheObject>
|
|
77
|
-
// ) => {
|
|
78
|
-
// return apolloClient
|
|
79
|
-
// .query({
|
|
80
|
-
// query: schema.FindCollectionsDocument,
|
|
81
|
-
// variables: { term, input, pageSize, pageToken },
|
|
82
|
-
// context: { uri: hosts.serverSearchHost },
|
|
83
|
-
// fetchPolicy: 'network-only',
|
|
84
|
-
// })
|
|
85
|
-
// .catch(() => {
|
|
86
|
-
// return {
|
|
87
|
-
// data: { findCollections: null },
|
|
88
|
-
// };
|
|
89
|
-
// });
|
|
90
|
-
// };
|
|
91
|
-
var maxCollectionsLength = 1000;
|
|
92
|
-
export var useFindCollections = function (_a) {
|
|
93
|
-
var term = _a.term, input = _a.input, page = _a.page;
|
|
94
|
-
var _b = useState([]), collections = _b[0], setCollections = _b[1];
|
|
95
|
-
var _c = useState(null), nextPageToken = _c[0], setNextPageToken = _c[1];
|
|
96
|
-
var _d = useState(0), results = _d[0], setResults = _d[1];
|
|
97
|
-
var openAlert = useUiStore(function (state) { return state.openAlert; });
|
|
98
|
-
var _e = useQuery(schema.FindCollectionsDocument, {
|
|
99
|
-
context: {
|
|
100
|
-
uri: hosts.searchHost,
|
|
101
|
-
},
|
|
102
|
-
variables: { term: term, input: input, page: page },
|
|
103
|
-
onCompleted: function (_a) {
|
|
104
|
-
var _b = _a.findCollections, collections = _b.collections, nextPageToken = _b.nextPageToken, results = _b.results;
|
|
105
|
-
setCollections(collections.map(function (collection) {
|
|
106
|
-
return new CollectionCreationEntity(__assign(__assign({}, collection), { name: collection.collectionTitle }), 'collection');
|
|
107
|
-
}));
|
|
108
|
-
setResults(results);
|
|
109
|
-
setNextPageToken(nextPageToken);
|
|
110
|
-
},
|
|
111
|
-
onError: function () {
|
|
112
|
-
openAlert({
|
|
113
|
-
type: alertVariants.error,
|
|
114
|
-
caption: 'Oops, something went wrong.',
|
|
115
|
-
});
|
|
116
|
-
setCollections([]);
|
|
117
|
-
setNextPageToken(null);
|
|
118
|
-
},
|
|
119
|
-
}), error = _e.error, loading = _e.loading, fetchMore = _e.fetchMore, refetch = _e.refetch;
|
|
120
|
-
return {
|
|
121
|
-
loadMore: loadMore,
|
|
122
|
-
loading: loading,
|
|
123
|
-
error: error,
|
|
124
|
-
results: results,
|
|
125
|
-
collections: collections,
|
|
126
|
-
nextPageToken: nextPageToken,
|
|
127
|
-
refetchQuery: refetchQuery,
|
|
128
|
-
};
|
|
129
|
-
function refetchQuery() {
|
|
130
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
131
|
-
return __generator(this, function (_a) {
|
|
132
|
-
switch (_a.label) {
|
|
133
|
-
case 0: return [4 /*yield*/, refetch()];
|
|
134
|
-
case 1:
|
|
135
|
-
_a.sent();
|
|
136
|
-
return [2 /*return*/];
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
function loadMore(pageToken) {
|
|
142
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
143
|
-
return __generator(this, function (_a) {
|
|
144
|
-
switch (_a.label) {
|
|
145
|
-
case 0:
|
|
146
|
-
if (!pageToken || collections.length >= maxCollectionsLength)
|
|
147
|
-
return [2 /*return*/];
|
|
148
|
-
return [4 /*yield*/, fetchMore({
|
|
149
|
-
variables: { pageToken: pageToken },
|
|
150
|
-
updateQuery: function (prev, _a) {
|
|
151
|
-
var fetchMoreResult = _a.fetchMoreResult;
|
|
152
|
-
if (!fetchMoreResult)
|
|
153
|
-
return prev;
|
|
154
|
-
var _b = fetchMoreResult.findCollections, nextCollections = _b.collections, rest = __rest(_b, ["collections"]);
|
|
155
|
-
if (prev !== null && prev.hasOwn('findCollections')) {
|
|
156
|
-
var prevCollections = prev.findCollections.collections;
|
|
157
|
-
return {
|
|
158
|
-
findCollections: __assign({ collections: __spreadArray(__spreadArray([], prevCollections, true), nextCollections, true) }, rest),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
return {
|
|
163
|
-
findCollections: __assign({ collections: nextCollections }, rest),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
})];
|
|
168
|
-
case 1:
|
|
169
|
-
_a.sent();
|
|
170
|
-
return [2 /*return*/];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
export default { /*prefetchFindCollections,*/ useFindCollections: useFindCollections };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { searchSchema as schema } from '@ludo.ninja/api';
|
|
2
|
-
import CollectionCreationEntity from '@/dto/Collection/CollectionCreationEntity';
|
|
3
|
-
declare const useFetchDynamicCollectionData: ({ input, }: schema.IQueryFetchDynamicCollectionDataArgs) => {
|
|
4
|
-
loadMore: (pageToken: string | null) => Promise<void>;
|
|
5
|
-
loading: boolean;
|
|
6
|
-
error: import("@apollo/client").ApolloError;
|
|
7
|
-
refetchQuery: () => Promise<void>;
|
|
8
|
-
collectionAssetsList: CollectionCreationEntity[];
|
|
9
|
-
nextPageToken: string;
|
|
10
|
-
likesCount: number;
|
|
11
|
-
isLikedByUser: boolean;
|
|
12
|
-
};
|
|
13
|
-
export { useFetchDynamicCollectionData };
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { useState } from 'react';
|
|
58
|
-
import { NetworkStatus, useQuery } from '@apollo/client';
|
|
59
|
-
import { hosts, searchSchema as schema } from '@ludo.ninja/api';
|
|
60
|
-
import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
|
|
61
|
-
import { useUiStore } from '@/store/ui';
|
|
62
|
-
import CollectionCreationEntity from '@/dto/Collection/CollectionCreationEntity';
|
|
63
|
-
var maxCollectionListLength = 1000;
|
|
64
|
-
var useFetchDynamicCollectionData = function (_a) {
|
|
65
|
-
var input = _a.input;
|
|
66
|
-
var _b = useState([]), collectionAssetsList = _b[0], setCollectionAssetsList = _b[1];
|
|
67
|
-
var page = input.page, collectionId = input.collectionId;
|
|
68
|
-
var openAlert = useUiStore(function (state) { return state.openAlert; });
|
|
69
|
-
var _c = useState(null), nextPageToken = _c[0], setNextPageToken = _c[1];
|
|
70
|
-
var _d = useState(0), likesCount = _d[0], setLikesCount = _d[1];
|
|
71
|
-
var _e = useState(false), isLikedByUser = _e[0], setIslikedByUser = _e[1];
|
|
72
|
-
var _f = useQuery(schema.FetchDynamicCollectionDataDocument, {
|
|
73
|
-
variables: { input: input },
|
|
74
|
-
context: {
|
|
75
|
-
uri: hosts.searchHost,
|
|
76
|
-
},
|
|
77
|
-
onCompleted: function (_a) {
|
|
78
|
-
var _b = _a.fetchDynamicCollectionData, isLikedByUser = _b.isLikedByUser, likesNum = _b.likesNum, _c = _b.collectionAssetsPage, nextPage = _c.nextPage, collectionAssets = _c.collectionAssets;
|
|
79
|
-
setLikesCount(likesNum);
|
|
80
|
-
setIslikedByUser(isLikedByUser);
|
|
81
|
-
setNextPageToken(nextPage.token);
|
|
82
|
-
setCollectionAssetsList(collectionAssets.map(function (collectionAsset) {
|
|
83
|
-
return new CollectionCreationEntity(__assign(__assign({}, collectionAsset), { collectionId: collectionAsset.assetId }));
|
|
84
|
-
}));
|
|
85
|
-
},
|
|
86
|
-
onError: function () {
|
|
87
|
-
openAlert({
|
|
88
|
-
type: alertVariants.error,
|
|
89
|
-
caption: 'Oops, something went wrong.',
|
|
90
|
-
});
|
|
91
|
-
setCollectionAssetsList([]);
|
|
92
|
-
setNextPageToken(null);
|
|
93
|
-
},
|
|
94
|
-
}), error = _f.error, loading = _f.loading, fetchMore = _f.fetchMore, networkStatus = _f.networkStatus, refetch = _f.refetch;
|
|
95
|
-
var loadingMorePosts = networkStatus === NetworkStatus.fetchMore;
|
|
96
|
-
return {
|
|
97
|
-
loadMore: loadMore,
|
|
98
|
-
loading: loading || loadingMorePosts,
|
|
99
|
-
error: error,
|
|
100
|
-
refetchQuery: refetchQuery,
|
|
101
|
-
collectionAssetsList: collectionAssetsList,
|
|
102
|
-
nextPageToken: nextPageToken,
|
|
103
|
-
likesCount: likesCount,
|
|
104
|
-
isLikedByUser: isLikedByUser,
|
|
105
|
-
};
|
|
106
|
-
function refetchQuery() {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
return __generator(this, function (_a) {
|
|
109
|
-
switch (_a.label) {
|
|
110
|
-
case 0: return [4 /*yield*/, refetch()];
|
|
111
|
-
case 1:
|
|
112
|
-
_a.sent();
|
|
113
|
-
return [2 /*return*/];
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function loadMore(pageToken) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
120
|
-
var data, _a, nextPage, nextCollectionAssetsList_1, error_1;
|
|
121
|
-
return __generator(this, function (_b) {
|
|
122
|
-
switch (_b.label) {
|
|
123
|
-
case 0:
|
|
124
|
-
if (!pageToken || collectionAssetsList.length >= maxCollectionListLength)
|
|
125
|
-
return [2 /*return*/];
|
|
126
|
-
_b.label = 1;
|
|
127
|
-
case 1:
|
|
128
|
-
_b.trys.push([1, 3, , 4]);
|
|
129
|
-
return [4 /*yield*/, fetchMore({
|
|
130
|
-
variables: {
|
|
131
|
-
input: { page: { token: pageToken, size: page === null || page === void 0 ? void 0 : page.size }, collectionId: collectionId },
|
|
132
|
-
},
|
|
133
|
-
})];
|
|
134
|
-
case 2:
|
|
135
|
-
data = (_b.sent()).data;
|
|
136
|
-
_a = data.fetchDynamicCollectionData.collectionAssetsPage, nextPage = _a.nextPage, nextCollectionAssetsList_1 = _a.collectionAssets;
|
|
137
|
-
setCollectionAssetsList(function (prevCollection) { return __spreadArray(__spreadArray([], prevCollection, true), nextCollectionAssetsList_1.map(function (collectionAsset) {
|
|
138
|
-
return new CollectionCreationEntity(__assign(__assign({}, collectionAsset), { collectionId: collectionAsset.assetId }));
|
|
139
|
-
}), true); });
|
|
140
|
-
setNextPageToken(nextPage.token);
|
|
141
|
-
return [3 /*break*/, 4];
|
|
142
|
-
case 3:
|
|
143
|
-
error_1 = _b.sent();
|
|
144
|
-
throw new Error(error_1);
|
|
145
|
-
case 4: return [2 /*return*/];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
// await fetchMore({
|
|
151
|
-
// variables: {
|
|
152
|
-
// input: { assetsPageToken: pageToken, assetsPageSize, collectionId },
|
|
153
|
-
// },
|
|
154
|
-
// updateQuery: (prev, { fetchMoreResult }) => {
|
|
155
|
-
// if (!fetchMoreResult) return prev;
|
|
156
|
-
// const {
|
|
157
|
-
// collectionAssetsPage: {
|
|
158
|
-
// nextPageToken,
|
|
159
|
-
// collectionAssets: nextCollectionAssetsList,
|
|
160
|
-
// },
|
|
161
|
-
// } = fetchMoreResult.fetchDynamicCollectionData;
|
|
162
|
-
// if (
|
|
163
|
-
// prev !== null &&
|
|
164
|
-
// prev.hasOwnProperty('fetchDynamicCollectionData')
|
|
165
|
-
// ) {
|
|
166
|
-
// const {
|
|
167
|
-
// collectionAssetsPage: {
|
|
168
|
-
// collectionAssets: prevCollectionAssetsList,
|
|
169
|
-
// },
|
|
170
|
-
// } = prev.fetchDynamicCollectionData;
|
|
171
|
-
// const updatedCollectionAssetsList = prevCollectionAssetsList.concat(
|
|
172
|
-
// nextCollectionAssetsList
|
|
173
|
-
// );
|
|
174
|
-
// return {
|
|
175
|
-
// fetchDynamicCollectionData: {
|
|
176
|
-
// collectionAssetsPage: {
|
|
177
|
-
// nextPageToken,
|
|
178
|
-
// collectionAssets: updatedCollectionAssetsList,
|
|
179
|
-
// },
|
|
180
|
-
// },
|
|
181
|
-
// };
|
|
182
|
-
// } else {
|
|
183
|
-
// return {
|
|
184
|
-
// fetchDynamicCollectionData: {
|
|
185
|
-
// collectionAssetsPage: {
|
|
186
|
-
// nextPageToken,
|
|
187
|
-
// collectionAssets: nextCollectionAssetsList,
|
|
188
|
-
// },
|
|
189
|
-
// },
|
|
190
|
-
// };
|
|
191
|
-
// }
|
|
192
|
-
// },
|
|
193
|
-
// });
|
|
194
|
-
};
|
|
195
|
-
export { useFetchDynamicCollectionData };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { hosts, searchSchema } from '@ludo.ninja/api';
|
|
3
|
-
import { ProfileEntity } from '@ludo.ninja/core';
|
|
4
|
-
import AssetEntity from '@/dto/AssetEntity';
|
|
5
|
-
export var prefetchFindAllTopEntitiesByName = function (_a, apolloClient) {
|
|
6
|
-
var name = _a.name, pageSize = _a.pageSize;
|
|
7
|
-
return apolloClient
|
|
8
|
-
.query({
|
|
9
|
-
query: searchSchema.FindAllTopEntitiesByNameDocument,
|
|
10
|
-
context: { uri: hosts.serverSearchHost },
|
|
11
|
-
variables: { name: name, pageSize: pageSize },
|
|
12
|
-
fetchPolicy: 'network-only',
|
|
13
|
-
})
|
|
14
|
-
.catch(function () {
|
|
15
|
-
return {
|
|
16
|
-
data: { findAllTopEntitiesByName: null },
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
export var useFetchFindAllTopEntitiesByName = function () {
|
|
21
|
-
var _a = useState(null), topEntities = _a[0], setTopEntities = _a[1];
|
|
22
|
-
var _b = searchSchema.useFindAllTopEntitiesByNameLazyQuery({
|
|
23
|
-
context: {
|
|
24
|
-
uri: hosts.searchHost,
|
|
25
|
-
},
|
|
26
|
-
onCompleted: function (_a) {
|
|
27
|
-
var findAllTopEntitiesByName = _a.findAllTopEntitiesByName;
|
|
28
|
-
var assets = findAllTopEntitiesByName.assets.map(function (asset) { return new AssetEntity(asset); }) || [];
|
|
29
|
-
var profiles = findAllTopEntitiesByName.profiles.map(function (profile) { return new ProfileEntity(profile); }) || [];
|
|
30
|
-
setTopEntities({
|
|
31
|
-
assets: assets,
|
|
32
|
-
collections: findAllTopEntitiesByName.collections,
|
|
33
|
-
profiles: profiles,
|
|
34
|
-
});
|
|
35
|
-
},
|
|
36
|
-
onError: function () {
|
|
37
|
-
setTopEntities(null);
|
|
38
|
-
},
|
|
39
|
-
}), findAllTopEntitiesByName = _b[0], _c = _b[1], data = _c.data, error = _c.error, loading = _c.loading;
|
|
40
|
-
function clearTopEntitiesState() {
|
|
41
|
-
setTopEntities(null);
|
|
42
|
-
}
|
|
43
|
-
function load(_a) {
|
|
44
|
-
var name = _a.name, pageSize = _a.pageSize;
|
|
45
|
-
return findAllTopEntitiesByName({
|
|
46
|
-
variables: { name: name, pageSize: pageSize },
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
return { data: data, loading: loading, error: error, load: load, topEntities: topEntities, clearTopEntitiesState: clearTopEntitiesState };
|
|
50
|
-
};
|
|
51
|
-
export default {
|
|
52
|
-
useFetchFindAllTopEntitiesByName: useFetchFindAllTopEntitiesByName,
|
|
53
|
-
prefetchFindAllTopEntitiesByName: prefetchFindAllTopEntitiesByName,
|
|
54
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import { useQuery } from '@apollo/client';
|
|
3
|
-
import { hosts, searchSchema as schema } from '@ludo.ninja/api';
|
|
4
|
-
var useFetchNetWorth = function (ownerId) {
|
|
5
|
-
var _a = useState(null), response = _a[0], setResponse = _a[1];
|
|
6
|
-
var _b = useQuery(schema.FetchUserPortfolioDocument, {
|
|
7
|
-
variables: { ownerId: ownerId },
|
|
8
|
-
context: {
|
|
9
|
-
uri: hosts.searchHost,
|
|
10
|
-
},
|
|
11
|
-
notifyOnNetworkStatusChange: true,
|
|
12
|
-
onCompleted: function (_a) {
|
|
13
|
-
var fetchUserPortfolio = _a.fetchUserPortfolio;
|
|
14
|
-
setResponse(fetchUserPortfolio);
|
|
15
|
-
},
|
|
16
|
-
onError: function () {
|
|
17
|
-
setResponse(null);
|
|
18
|
-
},
|
|
19
|
-
}), error = _b.error, loading = _b.loading;
|
|
20
|
-
return { response: response, loading: loading, error: error };
|
|
21
|
-
};
|
|
22
|
-
export default useFetchNetWorth;
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
-
var t = {};
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
|
-
if (ar || !(i in from)) {
|
|
62
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
63
|
-
ar[i] = from[i];
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
|
-
};
|
|
68
|
-
import { useState } from 'react';
|
|
69
|
-
import { NetworkStatus, } from '@apollo/client';
|
|
70
|
-
import { hosts, searchSchema as schema } from '@ludo.ninja/api';
|
|
71
|
-
import { alertVariants } from '@ludo.ninja/ui/build/system/Alert/type';
|
|
72
|
-
import { useUiStore } from '@/store/ui';
|
|
73
|
-
import CreationEntity from '@/dto/CreationEntity';
|
|
74
|
-
export var prefetchFindCreations = function (_a, apolloClient) {
|
|
75
|
-
var term = _a.term, input = _a.input, page = _a.page;
|
|
76
|
-
return apolloClient
|
|
77
|
-
.query({
|
|
78
|
-
query: schema.FindCreationsDocument,
|
|
79
|
-
variables: {
|
|
80
|
-
term: term,
|
|
81
|
-
input: input,
|
|
82
|
-
page: page,
|
|
83
|
-
},
|
|
84
|
-
context: { uri: hosts.serverSearchHost },
|
|
85
|
-
fetchPolicy: 'network-only',
|
|
86
|
-
})
|
|
87
|
-
.catch(function () {
|
|
88
|
-
return {
|
|
89
|
-
data: { findCreations: null },
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
var maxCreationLength = 1000;
|
|
94
|
-
export var useFindCreations = function (_a) {
|
|
95
|
-
var term = _a.term, input = _a.input, page = _a.page;
|
|
96
|
-
var _b = useState([]), creations = _b[0], setCreations = _b[1];
|
|
97
|
-
var _c = useState(null), nextPageToken = _c[0], setNextPageToken = _c[1];
|
|
98
|
-
var _d = useState(0), results = _d[0], setResults = _d[1];
|
|
99
|
-
var openAlert = useUiStore(function (state) { return state.openAlert; });
|
|
100
|
-
var _e = schema.useFindCreationsQuery({
|
|
101
|
-
context: {
|
|
102
|
-
uri: hosts.searchHost,
|
|
103
|
-
},
|
|
104
|
-
variables: {
|
|
105
|
-
term: term,
|
|
106
|
-
input: input,
|
|
107
|
-
page: page,
|
|
108
|
-
},
|
|
109
|
-
onCompleted: function (_a) {
|
|
110
|
-
var _b, _c;
|
|
111
|
-
var _d = _a.findCreations, creations = _d.creations, nextPage = __rest(_d, ["creations"]);
|
|
112
|
-
setCreations(creations.map(function (creation) { return new CreationEntity(creation); }));
|
|
113
|
-
setResults(((_b = nextPage.nextPage) === null || _b === void 0 ? void 0 : _b.elements) || 0);
|
|
114
|
-
setNextPageToken(((_c = nextPage.nextPage) === null || _c === void 0 ? void 0 : _c.token) || null);
|
|
115
|
-
},
|
|
116
|
-
onError: function () {
|
|
117
|
-
openAlert({
|
|
118
|
-
type: alertVariants.error,
|
|
119
|
-
caption: 'Oops, something went wrong.',
|
|
120
|
-
});
|
|
121
|
-
setCreations([]);
|
|
122
|
-
setNextPageToken(null);
|
|
123
|
-
},
|
|
124
|
-
}), error = _e.error, loading = _e.loading, fetchMore = _e.fetchMore, networkStatus = _e.networkStatus, refetch = _e.refetch;
|
|
125
|
-
var loadingMoreCreations = networkStatus === NetworkStatus.fetchMore;
|
|
126
|
-
return {
|
|
127
|
-
loadMore: loadMore,
|
|
128
|
-
loading: loading || loadingMoreCreations,
|
|
129
|
-
error: error,
|
|
130
|
-
results: results,
|
|
131
|
-
creations: creations,
|
|
132
|
-
nextPageToken: nextPageToken,
|
|
133
|
-
refetchQuery: refetchQuery,
|
|
134
|
-
};
|
|
135
|
-
function refetchQuery() {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
return __generator(this, function (_a) {
|
|
138
|
-
switch (_a.label) {
|
|
139
|
-
case 0: return [4 /*yield*/, refetch()];
|
|
140
|
-
case 1:
|
|
141
|
-
_a.sent();
|
|
142
|
-
return [2 /*return*/];
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function loadMore(pageToken) {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
-
return __generator(this, function (_a) {
|
|
150
|
-
switch (_a.label) {
|
|
151
|
-
case 0:
|
|
152
|
-
if (!pageToken || creations.length >= maxCreationLength)
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
return [4 /*yield*/, fetchMore({
|
|
155
|
-
variables: {
|
|
156
|
-
page: __assign({ token: pageToken }, (page && 'size' in page ? { size: page.size } : {})),
|
|
157
|
-
},
|
|
158
|
-
updateQuery: function (prev, _a) {
|
|
159
|
-
var fetchMoreResult = _a.fetchMoreResult;
|
|
160
|
-
if (!fetchMoreResult)
|
|
161
|
-
return prev;
|
|
162
|
-
var _b = fetchMoreResult.findCreations, nextCreations = _b.creations, page = __rest(_b, ["creations"]);
|
|
163
|
-
if (prev !== null) {
|
|
164
|
-
var prevCreations = prev.findCreations.creations;
|
|
165
|
-
return {
|
|
166
|
-
findCreations: __assign({ creations: __spreadArray(__spreadArray([], prevCreations, true), nextCreations, true) }, page),
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
return {
|
|
171
|
-
findCreations: __assign({ creations: nextCreations }, page),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
})];
|
|
176
|
-
case 1:
|
|
177
|
-
_a.sent();
|
|
178
|
-
return [2 /*return*/];
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
export default { useFindCreations: useFindCreations, prefetchFindCreations: prefetchFindCreations };
|