@replyke/core 7.0.0-beta.11 → 7.0.0-beta.13

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 (43) hide show
  1. package/dist/cjs/hooks/comments/index.d.ts +2 -1
  2. package/dist/cjs/hooks/comments/index.js +3 -3
  3. package/dist/cjs/hooks/comments/index.js.map +1 -1
  4. package/dist/cjs/hooks/comments/useFetchManyComments.d.ts +2 -2
  5. package/dist/cjs/hooks/comments/useFetchManyComments.js +5 -7
  6. package/dist/cjs/hooks/comments/useFetchManyComments.js.map +1 -1
  7. package/dist/cjs/hooks/comments/useFetchManyCommentsWrapper.d.ts +21 -0
  8. package/dist/cjs/hooks/comments/{useProfileComments.js → useFetchManyCommentsWrapper.js} +40 -18
  9. package/dist/cjs/hooks/comments/useFetchManyCommentsWrapper.js.map +1 -0
  10. package/dist/cjs/hooks/entities/index.d.ts +2 -0
  11. package/dist/cjs/hooks/entities/index.js +3 -1
  12. package/dist/cjs/hooks/entities/index.js.map +1 -1
  13. package/dist/cjs/hooks/entities/useFetchManyEntitiesWrapper.d.ts +41 -0
  14. package/dist/cjs/hooks/entities/useFetchManyEntitiesWrapper.js +241 -0
  15. package/dist/cjs/hooks/entities/useFetchManyEntitiesWrapper.js.map +1 -0
  16. package/dist/cjs/index.d.ts +2 -2
  17. package/dist/cjs/index.js +5 -4
  18. package/dist/cjs/index.js.map +1 -1
  19. package/dist/cjs/interfaces/models/Comment.d.ts +3 -0
  20. package/dist/esm/hooks/comments/index.d.ts +2 -1
  21. package/dist/esm/hooks/comments/index.js +1 -1
  22. package/dist/esm/hooks/comments/index.js.map +1 -1
  23. package/dist/esm/hooks/comments/useFetchManyComments.d.ts +2 -2
  24. package/dist/esm/hooks/comments/useFetchManyComments.js +5 -7
  25. package/dist/esm/hooks/comments/useFetchManyComments.js.map +1 -1
  26. package/dist/esm/hooks/comments/useFetchManyCommentsWrapper.d.ts +21 -0
  27. package/dist/esm/hooks/comments/{useProfileComments.js → useFetchManyCommentsWrapper.js} +40 -18
  28. package/dist/esm/hooks/comments/useFetchManyCommentsWrapper.js.map +1 -0
  29. package/dist/esm/hooks/entities/index.d.ts +2 -0
  30. package/dist/esm/hooks/entities/index.js +1 -0
  31. package/dist/esm/hooks/entities/index.js.map +1 -1
  32. package/dist/esm/hooks/entities/useFetchManyEntitiesWrapper.d.ts +41 -0
  33. package/dist/esm/hooks/entities/useFetchManyEntitiesWrapper.js +236 -0
  34. package/dist/esm/hooks/entities/useFetchManyEntitiesWrapper.js.map +1 -0
  35. package/dist/esm/index.d.ts +2 -2
  36. package/dist/esm/index.js +2 -2
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/interfaces/models/Comment.d.ts +3 -0
  39. package/package.json +1 -1
  40. package/dist/cjs/hooks/comments/useProfileComments.d.ts +0 -18
  41. package/dist/cjs/hooks/comments/useProfileComments.js.map +0 -1
  42. package/dist/esm/hooks/comments/useProfileComments.d.ts +0 -18
  43. package/dist/esm/hooks/comments/useProfileComments.js.map +0 -1
package/dist/cjs/index.js CHANGED
@@ -36,9 +36,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.useFetchManySpaces = exports.useFetchSpaceChildren = exports.useFetchSpaceBreadcrumb = exports.useFetchSpaceBySlug = exports.useFetchSpaceByShortId = exports.useFetchSpace = exports.useSpaceData = exports.useSpace = exports.useEntityListActions = exports.useEntityList = exports.useUpvoteEntity = exports.useUpdateEntity = exports.useRemoveEntityUpvote = exports.useRemoveEntityDownvote = exports.useIncrementEntityViews = exports.useFetchManyEntities = exports.useFetchEntityByShortId = exports.useFetchEntityByForeignId = exports.useFetchEntity = exports.useEntityVotes = exports.useDownvoteEntity = exports.useDeleteEntity = exports.useCreateEntity = exports.useEntityData = exports.useEntity = exports.useIsEntitySaved = exports.useListsActions = exports.useLists = exports.useAppNotificationsActions = exports.useAppNotifications = exports.useUserActions = exports.useUser = exports.useAuth = exports.useSignTestingJwt = exports.useProjectData = exports.useProject = exports.SpaceProvider = exports.CommentSectionProvider = exports.EntityProvider = exports.ReplykeProvider = exports.reportReasons = exports.getEnvVar = exports.getApiBaseUrl = exports.isProduction = exports.isDevelopment = exports.getPublicFileUrl = exports.getUserName = exports.safeMergeStyleProps = exports.keywordHelpers = exports.handleError = void 0;
40
- exports.useDeclineConnection = exports.useAcceptConnection = exports.useRequestConnection = exports.useUnfollowUserByUserId = exports.useUnfollowByFollowId = exports.useFollowUser = exports.useFollowManager = exports.useFetchFollowingCountByUserId = exports.useFetchFollowingCount = exports.useFetchFollowingByUserId = exports.useFetchFollowing = exports.useFetchFollowersCountByUserId = exports.useFetchFollowersCount = exports.useFetchFollowersByUserId = exports.useFetchFollowers = exports.useFetchFollowStatus = exports.useUpdateUser = exports.useMentions = exports.useFetchUserSuggestions = exports.useCheckUsernameAvailability = exports.useFetchUserByUsername = exports.useFetchUserByForeignId = exports.useFetchUser = exports.useProfileComments = exports.useEntityComments = exports.useDeleteComment = exports.useCommentVotes = exports.useUpdateComment = exports.useReplies = exports.useFetchCommentByForeignId = exports.useFetchComment = exports.useFetchManyComments = exports.useCreateComment = exports.useCommentSectionData = exports.useCommentSection = exports.useSpaceListActions = exports.useSpaceList = exports.useSpacePermissions = exports.useRemoveMember = exports.useDeclineMember = exports.useApproveMember = exports.useUpdateMemberRole = exports.useFetchMySpaces = exports.useFetchSpaceMembers = exports.useLeaveSpace = exports.useJoinSpace = exports.useDeleteSpace = exports.useUpdateSpace = exports.useCreateSpace = exports.useCheckSlugAvailability = void 0;
41
- exports.validateSortType = exports.validateMetadataPropertyName = exports.validateSortBy = exports.AppNotification = exports.useUploadFile = exports.useGetMetadata = exports.useHandleSpaceCommentReport = exports.useHandleSpaceEntityReport = exports.useFetchSpaceReports = exports.useCreateReport = exports.useConnectionManager = exports.useFetchConnectionsCountByUserId = exports.useFetchConnectionsByUserId = exports.useFetchReceivedPendingConnections = exports.useFetchSentPendingConnections = exports.useFetchConnectionsCount = exports.useRemoveConnectionByUserId = exports.useFetchConnectionStatus = exports.useFetchConnections = exports.useRemoveConnection = void 0;
39
+ exports.useFetchSpaceChildren = exports.useFetchSpaceBreadcrumb = exports.useFetchSpaceBySlug = exports.useFetchSpaceByShortId = exports.useFetchSpace = exports.useSpaceData = exports.useSpace = exports.useEntityListActions = exports.useEntityList = exports.useUpvoteEntity = exports.useUpdateEntity = exports.useRemoveEntityUpvote = exports.useRemoveEntityDownvote = exports.useFetchManyEntitiesWrapper = exports.useIncrementEntityViews = exports.useFetchManyEntities = exports.useFetchEntityByShortId = exports.useFetchEntityByForeignId = exports.useFetchEntity = exports.useEntityVotes = exports.useDownvoteEntity = exports.useDeleteEntity = exports.useCreateEntity = exports.useEntityData = exports.useEntity = exports.useIsEntitySaved = exports.useListsActions = exports.useLists = exports.useAppNotificationsActions = exports.useAppNotifications = exports.useUserActions = exports.useUser = exports.useAuth = exports.useSignTestingJwt = exports.useProjectData = exports.useProject = exports.SpaceProvider = exports.CommentSectionProvider = exports.EntityProvider = exports.ReplykeProvider = exports.reportReasons = exports.getEnvVar = exports.getApiBaseUrl = exports.isProduction = exports.isDevelopment = exports.getPublicFileUrl = exports.getUserName = exports.safeMergeStyleProps = exports.keywordHelpers = exports.handleError = void 0;
40
+ exports.useAcceptConnection = exports.useRequestConnection = exports.useUnfollowUserByUserId = exports.useUnfollowByFollowId = exports.useFollowUser = exports.useFollowManager = exports.useFetchFollowingCountByUserId = exports.useFetchFollowingCount = exports.useFetchFollowingByUserId = exports.useFetchFollowing = exports.useFetchFollowersCountByUserId = exports.useFetchFollowersCount = exports.useFetchFollowersByUserId = exports.useFetchFollowers = exports.useFetchFollowStatus = exports.useUpdateUser = exports.useMentions = exports.useFetchUserSuggestions = exports.useCheckUsernameAvailability = exports.useFetchUserByUsername = exports.useFetchUserByForeignId = exports.useFetchUser = exports.useFetchManyCommentsWrapper = exports.useEntityComments = exports.useDeleteComment = exports.useCommentVotes = exports.useUpdateComment = exports.useReplies = exports.useFetchCommentByForeignId = exports.useFetchComment = exports.useFetchManyComments = exports.useCreateComment = exports.useCommentSectionData = exports.useCommentSection = exports.useSpaceListActions = exports.useSpaceList = exports.useSpacePermissions = exports.useRemoveMember = exports.useDeclineMember = exports.useApproveMember = exports.useUpdateMemberRole = exports.useFetchMySpaces = exports.useFetchSpaceMembers = exports.useLeaveSpace = exports.useJoinSpace = exports.useDeleteSpace = exports.useUpdateSpace = exports.useCreateSpace = exports.useCheckSlugAvailability = exports.useFetchManySpaces = void 0;
41
+ exports.validateSortType = exports.validateMetadataPropertyName = exports.validateSortBy = exports.AppNotification = exports.useUploadFile = exports.useGetMetadata = exports.useHandleSpaceCommentReport = exports.useHandleSpaceEntityReport = exports.useFetchSpaceReports = exports.useCreateReport = exports.useConnectionManager = exports.useFetchConnectionsCountByUserId = exports.useFetchConnectionsByUserId = exports.useFetchReceivedPendingConnections = exports.useFetchSentPendingConnections = exports.useFetchConnectionsCount = exports.useRemoveConnectionByUserId = exports.useFetchConnectionStatus = exports.useFetchConnections = exports.useRemoveConnection = exports.useDeclineConnection = void 0;
42
42
  // Helpers & Utilities
43
43
  var handleError_1 = require("./utils/handleError");
44
44
  Object.defineProperty(exports, "handleError", { enumerable: true, get: function () { return handleError_1.handleError; } });
@@ -100,6 +100,7 @@ Object.defineProperty(exports, "useFetchEntityByForeignId", { enumerable: true,
100
100
  Object.defineProperty(exports, "useFetchEntityByShortId", { enumerable: true, get: function () { return entities_1.useFetchEntityByShortId; } });
101
101
  Object.defineProperty(exports, "useFetchManyEntities", { enumerable: true, get: function () { return entities_1.useFetchManyEntities; } });
102
102
  Object.defineProperty(exports, "useIncrementEntityViews", { enumerable: true, get: function () { return entities_1.useIncrementEntityViews; } });
103
+ Object.defineProperty(exports, "useFetchManyEntitiesWrapper", { enumerable: true, get: function () { return entities_1.useFetchManyEntitiesWrapper; } });
103
104
  Object.defineProperty(exports, "useRemoveEntityDownvote", { enumerable: true, get: function () { return entities_1.useRemoveEntityDownvote; } });
104
105
  Object.defineProperty(exports, "useRemoveEntityUpvote", { enumerable: true, get: function () { return entities_1.useRemoveEntityUpvote; } });
105
106
  Object.defineProperty(exports, "useUpdateEntity", { enumerable: true, get: function () { return entities_1.useUpdateEntity; } });
@@ -148,7 +149,7 @@ Object.defineProperty(exports, "useUpdateComment", { enumerable: true, get: func
148
149
  Object.defineProperty(exports, "useCommentVotes", { enumerable: true, get: function () { return comments_1.useCommentVotes; } });
149
150
  Object.defineProperty(exports, "useDeleteComment", { enumerable: true, get: function () { return comments_1.useDeleteComment; } });
150
151
  Object.defineProperty(exports, "useEntityComments", { enumerable: true, get: function () { return comments_1.useEntityComments; } });
151
- Object.defineProperty(exports, "useProfileComments", { enumerable: true, get: function () { return comments_1.useProfileComments; } });
152
+ Object.defineProperty(exports, "useFetchManyCommentsWrapper", { enumerable: true, get: function () { return comments_1.useFetchManyCommentsWrapper; } });
152
153
  // -- users
153
154
  var users_1 = require("./hooks/users");
154
155
  Object.defineProperty(exports, "useFetchUser", { enumerable: true, get: function () { return users_1.useFetchUser; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sBAAsB;AACtB,mDAAkD;AAAzC,0GAAA,WAAW,OAAA;AACpB,yDAAwD;AAA/C,gHAAA,cAAc,OAAA;AACvB,qEAAoE;AAA3D,0HAAA,mBAAmB,OAAA;AAC5B,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,+DAAyE;AAAhE,qIAAA,OAAO,OAAoB;AACpC,mCAKqB;AAJnB,oGAAA,aAAa,OAAA;AACb,mGAAA,YAAY,OAAA;AACZ,oGAAA,aAAa,OAAA;AACb,gGAAA,SAAS,OAAA;AAGX,YAAY;AACZ,2DAA0D;AAAjD,8GAAA,aAAa,OAAA;AAGt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b,2CAAgD;AAAvC,wGAAA,aAAa,OAAA;AActB,uFAAuE;AAwCvE,gFAI8C;AAH5C,yHAAA,cAAc,OAAA;AACd,uIAAA,4BAA4B,OAAA;AAC5B,2HAAA,gBAAgB,OAAA"}
@@ -30,3 +30,6 @@ export interface Comment {
30
30
  deletedAt: Date | null;
31
31
  parentDeletedAt: Date | null;
32
32
  }
33
+ export type CommentInclude = "entity";
34
+ export type CommentIncludeArray = CommentInclude[];
35
+ export type CommentIncludeParam = string | CommentIncludeArray;
@@ -9,4 +9,5 @@ export { default as useUpdateComment } from "./useUpdateComment";
9
9
  export { default as useCommentVotes } from "./useCommentVotes";
10
10
  export { default as useDeleteComment } from "./useDeleteComment";
11
11
  export { default as useEntityComments } from "./useEntityComments";
12
- export { default as useProfileComments } from "./useProfileComments";
12
+ export { default as useFetchManyCommentsWrapper } from "./useFetchManyCommentsWrapper";
13
+ export type { UseFetchManyCommentsWrapperProps, UseFetchManyCommentsWrapperValues, } from "./useFetchManyCommentsWrapper";
@@ -9,5 +9,5 @@ export { default as useUpdateComment } from "./useUpdateComment";
9
9
  export { default as useCommentVotes } from "./useCommentVotes";
10
10
  export { default as useDeleteComment } from "./useDeleteComment";
11
11
  export { default as useEntityComments } from "./useEntityComments";
12
- export { default as useProfileComments } from "./useProfileComments";
12
+ export { default as useFetchManyCommentsWrapper } from "./useFetchManyCommentsWrapper";
13
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/comments/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;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AACjE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { CommentsSortByOptions } from "../../interfaces/CommentsSortByOptions";
2
- import { Comment } from "../../interfaces/models/Comment";
2
+ import { Comment, CommentIncludeParam } from "../../interfaces/models/Comment";
3
3
  import { PaginatedResponse } from "../../interfaces/IPaginatedResponse";
4
4
  declare function useFetchManyComments(): (props: {
5
5
  entityId?: string | null | undefined;
@@ -8,7 +8,7 @@ declare function useFetchManyComments(): (props: {
8
8
  sortBy?: CommentsSortByOptions;
9
9
  page: number;
10
10
  limit?: number;
11
- includeEntity?: boolean;
11
+ include?: CommentIncludeParam;
12
12
  sourceId?: string | null | undefined;
13
13
  }) => Promise<PaginatedResponse<Comment>>;
14
14
  export default useFetchManyComments;
@@ -41,20 +41,17 @@ function useFetchManyComments() {
41
41
  var _this = this;
42
42
  var projectId = useProject().projectId;
43
43
  var fetchComments = useCallback(function (props) { return __awaiter(_this, void 0, void 0, function () {
44
- var entityId, userId, parentId, sortBy, page, limit, includeEntity, sourceId, params, response;
44
+ var entityId, userId, parentId, sortBy, page, limit, include, sourceId, params, response;
45
45
  return __generator(this, function (_a) {
46
46
  switch (_a.label) {
47
47
  case 0:
48
- entityId = props.entityId, userId = props.userId, parentId = props.parentId, sortBy = props.sortBy, page = props.page, limit = props.limit, includeEntity = props.includeEntity, sourceId = props.sourceId;
48
+ entityId = props.entityId, userId = props.userId, parentId = props.parentId, sortBy = props.sortBy, page = props.page, limit = props.limit, include = props.include, sourceId = props.sourceId;
49
49
  if (page === 0) {
50
50
  throw new Error("Can't fetch comments with page 0");
51
51
  }
52
52
  if (limit === 0) {
53
53
  throw new Error("Can't fetch with limit 0");
54
54
  }
55
- if (!sortBy) {
56
- throw new Error("Can't fetch without sortBy property");
57
- }
58
55
  if (!projectId) {
59
56
  throw new Error("No project specified");
60
57
  }
@@ -69,10 +66,11 @@ function useFetchManyComments() {
69
66
  params.userId = userId;
70
67
  if (parentId)
71
68
  params.parentId = parentId;
72
- if (includeEntity)
73
- params.includeEntity = includeEntity;
74
69
  if (sourceId)
75
70
  params.sourceId = sourceId;
71
+ if (include) {
72
+ params.include = Array.isArray(include) ? include.join(',') : include;
73
+ }
76
74
  return [4 /*yield*/, axios.get("/".concat(projectId, "/comments"), {
77
75
  params: params,
78
76
  })];
@@ -1 +1 @@
1
- {"version":3,"file":"useFetchManyComments.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useFetchManyComments.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIpC,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,MAAM,oBAAoB,CAAC;AAEvC,SAAS,oBAAoB;IAA7B,iBAiEC;IAhES,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IAEnC,IAAM,aAAa,GAAG,WAAW,CAC/B,UAAO,KASN;;;;;oBAEG,QAAQ,GAQN,KAAK,SARC,EACR,MAAM,GAOJ,KAAK,OAPD,EACN,QAAQ,GAMN,KAAK,SANC,EACR,MAAM,GAKJ,KAAK,OALD,EACN,IAAI,GAIF,KAAK,KAJH,EACJ,KAAK,GAGH,KAAK,MAHF,EACL,aAAa,GAEX,KAAK,cAFM,EACb,QAAQ,GACN,KAAK,SADC,CACA;oBAEV,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;oBACtD,CAAC;oBAED,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;wBAChB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;oBAC9C,CAAC;oBAED,IAAI,CAAC,MAAM,EAAE,CAAC;wBACZ,MAAM,IAAI,KAAK,CAA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AAO,QAAQ,CAAC,IAAI,EAAC;;;SACtB,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { CommentsSortByOptions } from "../../interfaces/CommentsSortByOptions";
2
+ import { Comment, CommentIncludeParam } from "../../interfaces/models/Comment";
3
+ export interface UseFetchManyCommentsWrapperProps {
4
+ entityId?: string | null;
5
+ userId?: string | null;
6
+ parentId?: string | null;
7
+ sourceId?: string | null;
8
+ limit?: number;
9
+ include?: CommentIncludeParam;
10
+ defaultSortBy?: CommentsSortByOptions;
11
+ }
12
+ export interface UseFetchManyCommentsWrapperValues {
13
+ comments: Comment[];
14
+ loading: boolean;
15
+ hasMore: boolean;
16
+ sortBy: CommentsSortByOptions | null;
17
+ setSortBy: (newSortBy: CommentsSortByOptions) => void;
18
+ loadMore: () => void;
19
+ }
20
+ declare function useFetchManyCommentsWrapper(props: UseFetchManyCommentsWrapperProps): UseFetchManyCommentsWrapperValues;
21
+ export default useFetchManyCommentsWrapper;
@@ -46,14 +46,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
46
46
  import { useCallback, useEffect, useRef, useState } from "react";
47
47
  import useFetchManyComments from "./useFetchManyComments";
48
48
  import { handleError } from "../../utils/handleError";
49
- function useProfileComments(props) {
49
+ function useFetchManyCommentsWrapper(props) {
50
50
  var _this = this;
51
- var userId = props.userId, _a = props.limit, limit = _a === void 0 ? 10 : _a, _b = props.defaultSortBy, defaultSortBy = _b === void 0 ? "new" : _b, includeEntity = props.includeEntity;
51
+ var entityId = props.entityId, userId = props.userId, parentId = props.parentId, sourceId = props.sourceId, _a = props.limit, limit = _a === void 0 ? 10 : _a, _b = props.defaultSortBy, defaultSortBy = _b === void 0 ? "new" : _b, include = props.include;
52
52
  var fetchManyComments = useFetchManyComments();
53
53
  var loading = useRef(true);
54
- var _c = useState(true), loadingState = _c[0], setLoadingState = _c[1]; // required to trigger rerenders
54
+ var _c = useState(true), loadingState = _c[0], setLoadingState = _c[1];
55
55
  var hasMore = useRef(true);
56
- var _d = useState(true), hasMoreState = _d[0], setHasMoreState = _d[1]; // required to trigger rerenders
56
+ var _d = useState(true), hasMoreState = _d[0], setHasMoreState = _d[1];
57
57
  var _e = useState(defaultSortBy), sortBy = _e[0], setSortBy = _e[1];
58
58
  var _f = useState(1), page = _f[0], setPage = _f[1];
59
59
  var _g = useState([]), comments = _g[0], setComments = _g[1];
@@ -62,10 +62,7 @@ function useProfileComments(props) {
62
62
  return __generator(this, function (_a) {
63
63
  switch (_a.label) {
64
64
  case 0:
65
- if (!userId) {
66
- // console.warn(
67
- // "The 'fetch comments' operation was invoked without a valid user and has been aborted."
68
- // );
65
+ if (!userId && !entityId && !parentId) {
69
66
  return [2 /*return*/];
70
67
  }
71
68
  _a.label = 1;
@@ -77,11 +74,14 @@ function useProfileComments(props) {
77
74
  setHasMoreState(true);
78
75
  setPage(1);
79
76
  return [4 /*yield*/, fetchManyComments({
77
+ entityId: entityId,
80
78
  userId: userId,
79
+ parentId: parentId,
80
+ sourceId: sourceId,
81
81
  page: 1,
82
82
  sortBy: sortBy,
83
- limit: 10,
84
- includeEntity: includeEntity,
83
+ limit: limit,
84
+ include: include,
85
85
  })];
86
86
  case 2:
87
87
  response = _a.sent();
@@ -94,7 +94,7 @@ function useProfileComments(props) {
94
94
  return [3 /*break*/, 5];
95
95
  case 3:
96
96
  err_1 = _a.sent();
97
- handleError(err_1, "Failed to reset profile comments:");
97
+ handleError(err_1, "Failed to reset comments:");
98
98
  return [3 /*break*/, 5];
99
99
  case 4:
100
100
  loading.current = false;
@@ -103,7 +103,16 @@ function useProfileComments(props) {
103
103
  case 5: return [2 /*return*/];
104
104
  }
105
105
  });
106
- }); }, [fetchManyComments, limit, sortBy, userId, includeEntity]);
106
+ }); }, [
107
+ fetchManyComments,
108
+ limit,
109
+ sortBy,
110
+ entityId,
111
+ userId,
112
+ parentId,
113
+ sourceId,
114
+ include,
115
+ ]);
107
116
  var loadMore = function () {
108
117
  if (loading.current || !hasMore.current)
109
118
  return;
@@ -114,7 +123,7 @@ function useProfileComments(props) {
114
123
  useEffect(function () {
115
124
  resetComments();
116
125
  }, [resetComments]);
117
- // useEffect to get a new batch of entities
126
+ // useEffect to get a new batch of comments
118
127
  useEffect(function () {
119
128
  var loadMoreComments = function () { return __awaiter(_this, void 0, void 0, function () {
120
129
  var response, newComments_1, pagination, err_2;
@@ -127,11 +136,14 @@ function useProfileComments(props) {
127
136
  case 1:
128
137
  _a.trys.push([1, 3, 4, 5]);
129
138
  return [4 /*yield*/, fetchManyComments({
139
+ entityId: entityId,
130
140
  userId: userId,
141
+ parentId: parentId,
142
+ sourceId: sourceId,
131
143
  page: page,
132
144
  sortBy: sortBy,
133
145
  limit: limit,
134
- includeEntity: includeEntity,
146
+ include: include,
135
147
  })];
136
148
  case 2:
137
149
  response = _a.sent();
@@ -154,11 +166,21 @@ function useProfileComments(props) {
154
166
  }
155
167
  });
156
168
  }); };
157
- // We only load more if th page changed
169
+ // We only load more if the page changed
158
170
  if (page > 1 && hasMore.current && !loading.current) {
159
171
  loadMoreComments();
160
172
  }
161
- }, [page]);
173
+ }, [
174
+ page,
175
+ fetchManyComments,
176
+ entityId,
177
+ userId,
178
+ parentId,
179
+ sourceId,
180
+ sortBy,
181
+ limit,
182
+ include,
183
+ ]);
162
184
  return {
163
185
  comments: comments,
164
186
  loading: loadingState,
@@ -168,5 +190,5 @@ function useProfileComments(props) {
168
190
  loadMore: loadMore,
169
191
  };
170
192
  }
171
- export default useProfileComments;
172
- //# sourceMappingURL=useProfileComments.js.map
193
+ export default useFetchManyCommentsWrapper;
194
+ //# sourceMappingURL=useFetchManyCommentsWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFetchManyCommentsWrapper.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useFetchManyCommentsWrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;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E,YAAY;QACrB,OAAO,EAAE,YAAY;QACrB,MAAM,QAAA;QACN,SAAS,WAAA;QACT,QAAQ,UAAA;KACT,CAAC;AACJ,CAAC;AAED,eAAe,2BAA2B,CAAC"}
@@ -9,6 +9,8 @@ export { default as useFetchEntityByForeignId } from "./useFetchEntityByForeignI
9
9
  export { default as useFetchEntityByShortId } from "./useFetchEntityByShortId";
10
10
  export { default as useFetchManyEntities } from "./useFetchManyEntities";
11
11
  export { default as useIncrementEntityViews } from "./useIncrementEntityViews";
12
+ export { default as useFetchManyEntitiesWrapper } from "./useFetchManyEntitiesWrapper";
13
+ export type { UseFetchManyEntitiesWrapperProps, UseFetchManyEntitiesWrapperValues, } from "./useFetchManyEntitiesWrapper";
12
14
  export { default as useRemoveEntityDownvote } from "./useRemoveEntityDownvote";
13
15
  export { default as useRemoveEntityUpvote } from "./useRemoveEntityUpvote";
14
16
  export { default as useUpdateEntity } from "./useUpdateEntity";
@@ -9,6 +9,7 @@ export { default as useFetchEntityByForeignId } from "./useFetchEntityByForeignI
9
9
  export { default as useFetchEntityByShortId } from "./useFetchEntityByShortId";
10
10
  export { default as useFetchManyEntities } from "./useFetchManyEntities";
11
11
  export { default as useIncrementEntityViews } from "./useIncrementEntityViews";
12
+ export { default as useFetchManyEntitiesWrapper } from "./useFetchManyEntitiesWrapper";
12
13
  export { default as useRemoveEntityDownvote } from "./useRemoveEntityDownvote";
13
14
  export { default as useRemoveEntityUpvote } from "./useRemoveEntityUpvote";
14
15
  export { default as useUpdateEntity } from "./useUpdateEntity";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/entities/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/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7D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAKvF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { EntityListSortByOptions, SortDirection, SortType } from "../../interfaces/EntityListSortByOptions";
2
+ import { Entity, EntityIncludeParam } from "../../interfaces/models/Entity";
3
+ import { TimeFrame } from "../../interfaces/TimeFrame";
4
+ import { KeywordsFilters } from "../../interfaces/entity-filters/KeywordsFilters";
5
+ import { TitleFilters } from "../../interfaces/entity-filters/TitleFilters";
6
+ import { ContentFilters } from "../../interfaces/entity-filters/ContentFilters";
7
+ import { AttachmentsFilters } from "../../interfaces/entity-filters/AttachmentsFilters";
8
+ import { LocationFilters } from "../../interfaces/entity-filters/LocationFilters";
9
+ import { MetadataFilters } from "../../interfaces/entity-filters/MetadataFilters";
10
+ export interface UseFetchManyEntitiesWrapperProps {
11
+ userId?: string | null;
12
+ limit?: number;
13
+ sourceId?: string | null;
14
+ spaceId?: string | null;
15
+ followedOnly?: boolean;
16
+ include?: EntityIncludeParam;
17
+ defaultSortBy?: EntityListSortByOptions;
18
+ defaultSortDir?: SortDirection;
19
+ defaultSortType?: SortType;
20
+ timeFrame?: TimeFrame | null;
21
+ keywordsFilters?: KeywordsFilters | null;
22
+ titleFilters?: TitleFilters | null;
23
+ contentFilters?: ContentFilters | null;
24
+ attachmentsFilters?: AttachmentsFilters | null;
25
+ locationFilters?: LocationFilters | null;
26
+ metadataFilters?: MetadataFilters | null;
27
+ }
28
+ export interface UseFetchManyEntitiesWrapperValues {
29
+ entities: Entity[];
30
+ loading: boolean;
31
+ hasMore: boolean;
32
+ sortBy: EntityListSortByOptions;
33
+ sortDir: SortDirection;
34
+ sortType: SortType;
35
+ setSortBy: (newSortBy: EntityListSortByOptions) => void;
36
+ setSortDir: (newSortDir: SortDirection) => void;
37
+ setSortType: (newSortType: SortType) => void;
38
+ loadMore: () => void;
39
+ }
40
+ declare function useFetchManyEntitiesWrapper(props: UseFetchManyEntitiesWrapperProps): UseFetchManyEntitiesWrapperValues;
41
+ export default useFetchManyEntitiesWrapper;
@@ -0,0 +1,236 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
38
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
39
+ if (ar || !(i in from)) {
40
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
41
+ ar[i] = from[i];
42
+ }
43
+ }
44
+ return to.concat(ar || Array.prototype.slice.call(from));
45
+ };
46
+ import { useCallback, useEffect, useRef, useState } from "react";
47
+ import useFetchManyEntities from "./useFetchManyEntities";
48
+ import { handleError } from "../../utils/handleError";
49
+ function useFetchManyEntitiesWrapper(props) {
50
+ var _this = this;
51
+ var userId = props.userId, _a = props.limit, limit = _a === void 0 ? 10 : _a, _b = props.defaultSortBy, defaultSortBy = _b === void 0 ? "new" : _b, _c = props.defaultSortDir, defaultSortDir = _c === void 0 ? "desc" : _c, _d = props.defaultSortType, defaultSortType = _d === void 0 ? "auto" : _d, timeFrame = props.timeFrame, sourceId = props.sourceId, spaceId = props.spaceId, include = props.include, followedOnly = props.followedOnly, keywordsFilters = props.keywordsFilters, titleFilters = props.titleFilters, contentFilters = props.contentFilters, attachmentsFilters = props.attachmentsFilters, locationFilters = props.locationFilters, metadataFilters = props.metadataFilters;
52
+ var fetchManyEntities = useFetchManyEntities();
53
+ var loading = useRef(true);
54
+ var _e = useState(true), loadingState = _e[0], setLoadingState = _e[1];
55
+ var hasMore = useRef(true);
56
+ var _f = useState(true), hasMoreState = _f[0], setHasMoreState = _f[1];
57
+ var _g = useState(defaultSortBy), sortBy = _g[0], setSortBy = _g[1];
58
+ var _h = useState(defaultSortDir), sortDir = _h[0], setSortDir = _h[1];
59
+ var _j = useState(defaultSortType), sortType = _j[0], setSortType = _j[1];
60
+ var _k = useState(1), page = _k[0], setPage = _k[1];
61
+ var _l = useState([]), entities = _l[0], setEntities = _l[1];
62
+ var resetEntities = useCallback(function () { return __awaiter(_this, void 0, void 0, function () {
63
+ var response, newEntities, pagination, err_1;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ if (!userId) {
68
+ return [2 /*return*/];
69
+ }
70
+ _a.label = 1;
71
+ case 1:
72
+ _a.trys.push([1, 3, 4, 5]);
73
+ loading.current = true;
74
+ setLoadingState(true);
75
+ hasMore.current = true;
76
+ setHasMoreState(true);
77
+ setPage(1);
78
+ return [4 /*yield*/, fetchManyEntities({
79
+ userId: userId,
80
+ page: 1,
81
+ sortBy: sortBy,
82
+ sortDir: sortDir,
83
+ sortType: sortType,
84
+ timeFrame: timeFrame,
85
+ sourceId: sourceId,
86
+ spaceId: spaceId,
87
+ limit: limit,
88
+ include: include,
89
+ followedOnly: followedOnly,
90
+ keywordsFilters: keywordsFilters,
91
+ titleFilters: titleFilters,
92
+ contentFilters: contentFilters,
93
+ attachmentsFilters: attachmentsFilters,
94
+ locationFilters: locationFilters,
95
+ metadataFilters: metadataFilters,
96
+ })];
97
+ case 2:
98
+ response = _a.sent();
99
+ if (response) {
100
+ newEntities = response.data, pagination = response.pagination;
101
+ setEntities(newEntities);
102
+ hasMore.current = pagination.hasMore;
103
+ setHasMoreState(pagination.hasMore);
104
+ }
105
+ return [3 /*break*/, 5];
106
+ case 3:
107
+ err_1 = _a.sent();
108
+ handleError(err_1, "Failed to reset profile entities:");
109
+ return [3 /*break*/, 5];
110
+ case 4:
111
+ loading.current = false;
112
+ setLoadingState(false);
113
+ return [7 /*endfinally*/];
114
+ case 5: return [2 /*return*/];
115
+ }
116
+ });
117
+ }); }, [
118
+ fetchManyEntities,
119
+ limit,
120
+ sortBy,
121
+ sortDir,
122
+ sortType,
123
+ timeFrame,
124
+ sourceId,
125
+ spaceId,
126
+ userId,
127
+ include,
128
+ followedOnly,
129
+ keywordsFilters,
130
+ titleFilters,
131
+ contentFilters,
132
+ attachmentsFilters,
133
+ locationFilters,
134
+ metadataFilters,
135
+ ]);
136
+ var loadMore = function () {
137
+ if (loading.current || !hasMore.current)
138
+ return;
139
+ setPage(function (prevPage) {
140
+ return prevPage + 1;
141
+ });
142
+ };
143
+ useEffect(function () {
144
+ resetEntities();
145
+ }, [resetEntities]);
146
+ // useEffect to get a new batch of entities
147
+ useEffect(function () {
148
+ var loadMoreEntities = function () { return __awaiter(_this, void 0, void 0, function () {
149
+ var response, newEntities_1, pagination, err_2;
150
+ return __generator(this, function (_a) {
151
+ switch (_a.label) {
152
+ case 0:
153
+ loading.current = true;
154
+ setLoadingState(true);
155
+ _a.label = 1;
156
+ case 1:
157
+ _a.trys.push([1, 3, 4, 5]);
158
+ return [4 /*yield*/, fetchManyEntities({
159
+ userId: userId,
160
+ page: page,
161
+ sortBy: sortBy,
162
+ sortDir: sortDir,
163
+ sortType: sortType,
164
+ timeFrame: timeFrame,
165
+ sourceId: sourceId,
166
+ spaceId: spaceId,
167
+ limit: limit,
168
+ include: include,
169
+ followedOnly: followedOnly,
170
+ keywordsFilters: keywordsFilters,
171
+ titleFilters: titleFilters,
172
+ contentFilters: contentFilters,
173
+ attachmentsFilters: attachmentsFilters,
174
+ locationFilters: locationFilters,
175
+ metadataFilters: metadataFilters,
176
+ })];
177
+ case 2:
178
+ response = _a.sent();
179
+ if (response) {
180
+ newEntities_1 = response.data, pagination = response.pagination;
181
+ setEntities(function (prevEntities) { return __spreadArray(__spreadArray([], prevEntities, true), newEntities_1, true); });
182
+ hasMore.current = pagination.hasMore;
183
+ setHasMoreState(pagination.hasMore);
184
+ }
185
+ return [3 /*break*/, 5];
186
+ case 3:
187
+ err_2 = _a.sent();
188
+ handleError(err_2, "Loading more entities failed:");
189
+ return [3 /*break*/, 5];
190
+ case 4:
191
+ loading.current = false;
192
+ setLoadingState(false);
193
+ return [7 /*endfinally*/];
194
+ case 5: return [2 /*return*/];
195
+ }
196
+ });
197
+ }); };
198
+ // We only load more if the page changed
199
+ if (page > 1 && hasMore.current && !loading.current) {
200
+ loadMoreEntities();
201
+ }
202
+ }, [
203
+ page,
204
+ fetchManyEntities,
205
+ userId,
206
+ sortBy,
207
+ sortDir,
208
+ sortType,
209
+ timeFrame,
210
+ sourceId,
211
+ spaceId,
212
+ limit,
213
+ include,
214
+ followedOnly,
215
+ keywordsFilters,
216
+ titleFilters,
217
+ contentFilters,
218
+ attachmentsFilters,
219
+ locationFilters,
220
+ metadataFilters,
221
+ ]);
222
+ return {
223
+ entities: entities,
224
+ loading: loadingState,
225
+ hasMore: hasMoreState,
226
+ sortBy: sortBy,
227
+ sortDir: sortDir,
228
+ sortType: sortType,
229
+ setSortBy: setSortBy,
230
+ setSortDir: setSortDir,
231
+ setSortType: setSortType,
232
+ loadMore: loadMore,
233
+ };
234
+ }
235
+ export default useFetchManyEntitiesWrapper;
236
+ //# sourceMappingURL=useFetchManyEntitiesWrapper.js.map