@replyke/core 7.0.0-beta.23 → 7.0.0-beta.25
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/cjs/hooks/comments/index.d.ts +0 -1
- package/dist/cjs/hooks/comments/index.js +1 -3
- package/dist/cjs/hooks/comments/index.js.map +1 -1
- package/dist/cjs/hooks/comments/useCommentSectionData.js +10 -0
- package/dist/cjs/hooks/comments/useCommentSectionData.js.map +1 -1
- package/dist/cjs/hooks/entities/index.d.ts +0 -5
- package/dist/cjs/hooks/entities/index.js +1 -11
- package/dist/cjs/hooks/entities/index.js.map +1 -1
- package/dist/cjs/hooks/entities/useEntityData.d.ts +0 -6
- package/dist/cjs/hooks/entities/useEntityData.js +0 -11
- package/dist/cjs/hooks/entities/useEntityData.js.map +1 -1
- package/dist/cjs/hooks/reactions/index.d.ts +10 -0
- package/dist/cjs/hooks/reactions/index.js +21 -0
- package/dist/cjs/hooks/reactions/index.js.map +1 -0
- package/dist/cjs/hooks/reactions/useAddReaction.d.ts +9 -0
- package/dist/cjs/hooks/{comments/useDownvoteComment.js → reactions/useAddReaction.js} +19 -13
- package/dist/cjs/hooks/reactions/useAddReaction.js.map +1 -0
- package/dist/cjs/hooks/reactions/useFetchCommentReactions.d.ts +10 -0
- package/dist/cjs/hooks/{comments/useRemoveCommentUpvote.js → reactions/useFetchCommentReactions.js} +26 -13
- package/dist/cjs/hooks/reactions/useFetchCommentReactions.js.map +1 -0
- package/dist/cjs/hooks/reactions/useFetchCommentReactionsWrapper.d.ts +17 -0
- package/dist/cjs/hooks/reactions/useFetchCommentReactionsWrapper.js +170 -0
- package/dist/cjs/hooks/reactions/useFetchCommentReactionsWrapper.js.map +1 -0
- package/dist/cjs/hooks/reactions/useFetchEntityReactions.d.ts +10 -0
- package/dist/cjs/hooks/{entities/useDownvoteEntity.js → reactions/useFetchEntityReactions.js} +26 -13
- package/dist/cjs/hooks/reactions/useFetchEntityReactions.js.map +1 -0
- package/dist/cjs/hooks/reactions/useFetchEntityReactionsWrapper.d.ts +17 -0
- package/dist/cjs/hooks/reactions/useFetchEntityReactionsWrapper.js +170 -0
- package/dist/cjs/hooks/reactions/useFetchEntityReactionsWrapper.js.map +1 -0
- package/dist/cjs/hooks/reactions/useReactionToggle.d.ts +14 -0
- package/dist/cjs/hooks/{comments/useUpvoteComment.js → reactions/useReactionToggle.js} +45 -23
- package/dist/cjs/hooks/reactions/useReactionToggle.js.map +1 -0
- package/dist/cjs/hooks/reactions/useRemoveReaction.d.ts +7 -0
- package/dist/cjs/hooks/{comments/useRemoveCommentDownvote.js → reactions/useRemoveReaction.js} +16 -13
- package/dist/cjs/hooks/reactions/useRemoveReaction.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -2
- package/dist/cjs/index.js +12 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/interfaces/models/Comment.d.ts +3 -0
- package/dist/cjs/interfaces/models/Entity.d.ts +3 -0
- package/dist/cjs/interfaces/models/Reaction.d.ts +23 -0
- package/dist/cjs/interfaces/models/Reaction.js +3 -0
- package/dist/cjs/interfaces/models/Reaction.js.map +1 -0
- package/dist/cjs/store/slices/entityListsSlice.d.ts +132 -0
- package/dist/esm/hooks/comments/index.d.ts +0 -1
- package/dist/esm/hooks/comments/index.js +0 -1
- package/dist/esm/hooks/comments/index.js.map +1 -1
- package/dist/esm/hooks/comments/useCommentSectionData.js +10 -0
- package/dist/esm/hooks/comments/useCommentSectionData.js.map +1 -1
- package/dist/esm/hooks/entities/index.d.ts +0 -5
- package/dist/esm/hooks/entities/index.js +0 -5
- package/dist/esm/hooks/entities/index.js.map +1 -1
- package/dist/esm/hooks/entities/useEntityData.d.ts +0 -6
- package/dist/esm/hooks/entities/useEntityData.js +0 -11
- package/dist/esm/hooks/entities/useEntityData.js.map +1 -1
- package/dist/esm/hooks/reactions/index.d.ts +10 -0
- package/dist/esm/hooks/reactions/index.js +8 -0
- package/dist/esm/hooks/reactions/index.js.map +1 -0
- package/dist/esm/hooks/reactions/useAddReaction.d.ts +9 -0
- package/dist/esm/hooks/{comments/useDownvoteComment.js → reactions/useAddReaction.js} +19 -13
- package/dist/esm/hooks/reactions/useAddReaction.js.map +1 -0
- package/dist/esm/hooks/reactions/useFetchCommentReactions.d.ts +10 -0
- package/dist/esm/hooks/{comments/useRemoveCommentUpvote.js → reactions/useFetchCommentReactions.js} +26 -13
- package/dist/esm/hooks/reactions/useFetchCommentReactions.js.map +1 -0
- package/dist/esm/hooks/reactions/useFetchCommentReactionsWrapper.d.ts +17 -0
- package/dist/esm/hooks/reactions/useFetchCommentReactionsWrapper.js +165 -0
- package/dist/esm/hooks/reactions/useFetchCommentReactionsWrapper.js.map +1 -0
- package/dist/esm/hooks/reactions/useFetchEntityReactions.d.ts +10 -0
- package/dist/esm/hooks/{entities/useDownvoteEntity.js → reactions/useFetchEntityReactions.js} +26 -13
- package/dist/esm/hooks/reactions/useFetchEntityReactions.js.map +1 -0
- package/dist/esm/hooks/reactions/useFetchEntityReactionsWrapper.d.ts +17 -0
- package/dist/esm/hooks/reactions/useFetchEntityReactionsWrapper.js +165 -0
- package/dist/esm/hooks/reactions/useFetchEntityReactionsWrapper.js.map +1 -0
- package/dist/esm/hooks/reactions/useReactionToggle.d.ts +14 -0
- package/dist/esm/hooks/reactions/useReactionToggle.js +88 -0
- package/dist/esm/hooks/reactions/useReactionToggle.js.map +1 -0
- package/dist/esm/hooks/reactions/useRemoveReaction.d.ts +7 -0
- package/dist/esm/hooks/{comments/useRemoveCommentDownvote.js → reactions/useRemoveReaction.js} +16 -13
- package/dist/esm/hooks/reactions/useRemoveReaction.js.map +1 -0
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/interfaces/models/Comment.d.ts +3 -0
- package/dist/esm/interfaces/models/Entity.d.ts +3 -0
- package/dist/esm/interfaces/models/Reaction.d.ts +23 -0
- package/dist/esm/interfaces/models/Reaction.js +2 -0
- package/dist/esm/interfaces/models/Reaction.js.map +1 -0
- package/dist/esm/store/slices/entityListsSlice.d.ts +132 -0
- package/package.json +1 -1
- package/dist/cjs/hooks/comments/useCommentVotes.d.ts +0 -13
- package/dist/cjs/hooks/comments/useCommentVotes.js +0 -241
- package/dist/cjs/hooks/comments/useCommentVotes.js.map +0 -1
- package/dist/cjs/hooks/comments/useDownvoteComment.d.ts +0 -5
- package/dist/cjs/hooks/comments/useDownvoteComment.js.map +0 -1
- package/dist/cjs/hooks/comments/useRemoveCommentDownvote.d.ts +0 -5
- package/dist/cjs/hooks/comments/useRemoveCommentDownvote.js.map +0 -1
- package/dist/cjs/hooks/comments/useRemoveCommentUpvote.d.ts +0 -5
- package/dist/cjs/hooks/comments/useRemoveCommentUpvote.js.map +0 -1
- package/dist/cjs/hooks/comments/useUpvoteComment.d.ts +0 -5
- package/dist/cjs/hooks/comments/useUpvoteComment.js.map +0 -1
- package/dist/cjs/hooks/entities/useDownvoteEntity.d.ts +0 -5
- package/dist/cjs/hooks/entities/useDownvoteEntity.js.map +0 -1
- package/dist/cjs/hooks/entities/useEntityVotes.d.ts +0 -13
- package/dist/cjs/hooks/entities/useEntityVotes.js +0 -250
- package/dist/cjs/hooks/entities/useEntityVotes.js.map +0 -1
- package/dist/cjs/hooks/entities/useRemoveEntityDownvote.d.ts +0 -5
- package/dist/cjs/hooks/entities/useRemoveEntityDownvote.js +0 -71
- package/dist/cjs/hooks/entities/useRemoveEntityDownvote.js.map +0 -1
- package/dist/cjs/hooks/entities/useRemoveEntityUpvote.d.ts +0 -5
- package/dist/cjs/hooks/entities/useRemoveEntityUpvote.js +0 -71
- package/dist/cjs/hooks/entities/useRemoveEntityUpvote.js.map +0 -1
- package/dist/cjs/hooks/entities/useUpvoteEntity.d.ts +0 -5
- package/dist/cjs/hooks/entities/useUpvoteEntity.js +0 -71
- package/dist/cjs/hooks/entities/useUpvoteEntity.js.map +0 -1
- package/dist/esm/hooks/comments/useCommentVotes.d.ts +0 -13
- package/dist/esm/hooks/comments/useCommentVotes.js +0 -236
- package/dist/esm/hooks/comments/useCommentVotes.js.map +0 -1
- package/dist/esm/hooks/comments/useDownvoteComment.d.ts +0 -5
- package/dist/esm/hooks/comments/useDownvoteComment.js.map +0 -1
- package/dist/esm/hooks/comments/useRemoveCommentDownvote.d.ts +0 -5
- package/dist/esm/hooks/comments/useRemoveCommentDownvote.js.map +0 -1
- package/dist/esm/hooks/comments/useRemoveCommentUpvote.d.ts +0 -5
- package/dist/esm/hooks/comments/useRemoveCommentUpvote.js.map +0 -1
- package/dist/esm/hooks/comments/useUpvoteComment.d.ts +0 -5
- package/dist/esm/hooks/comments/useUpvoteComment.js +0 -66
- package/dist/esm/hooks/comments/useUpvoteComment.js.map +0 -1
- package/dist/esm/hooks/entities/useDownvoteEntity.d.ts +0 -5
- package/dist/esm/hooks/entities/useDownvoteEntity.js.map +0 -1
- package/dist/esm/hooks/entities/useEntityVotes.d.ts +0 -13
- package/dist/esm/hooks/entities/useEntityVotes.js +0 -245
- package/dist/esm/hooks/entities/useEntityVotes.js.map +0 -1
- package/dist/esm/hooks/entities/useRemoveEntityDownvote.d.ts +0 -5
- package/dist/esm/hooks/entities/useRemoveEntityDownvote.js +0 -66
- package/dist/esm/hooks/entities/useRemoveEntityDownvote.js.map +0 -1
- package/dist/esm/hooks/entities/useRemoveEntityUpvote.d.ts +0 -5
- package/dist/esm/hooks/entities/useRemoveEntityUpvote.js +0 -66
- package/dist/esm/hooks/entities/useRemoveEntityUpvote.js.map +0 -1
- package/dist/esm/hooks/entities/useUpvoteEntity.d.ts +0 -5
- package/dist/esm/hooks/entities/useUpvoteEntity.js +0 -66
- package/dist/esm/hooks/entities/useUpvoteEntity.js.map +0 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -13,11 +13,12 @@ export { useAuth, type UseAuthValues } from "./hooks/auth";
|
|
|
13
13
|
export { useUser, useUserActions, type UseUserProps, type UseUserValues, } from "./hooks/user";
|
|
14
14
|
export { useAppNotifications, useAppNotificationsActions, type UseAppNotificationsProps, type UseAppNotificationsValues, } from "./hooks/app-notifications";
|
|
15
15
|
export { useCollections, useCollectionsActions, useIsEntityInCollection, useCollectionEntitiesWrapper, type UseCollectionsProps, type UseCollectionsValues, type UseCollectionEntitiesWrapperProps, type UseCollectionEntitiesWrapperValues, } from "./hooks/collections";
|
|
16
|
-
export { useEntity, useEntityData, useCreateEntity, useDeleteEntity,
|
|
16
|
+
export { useEntity, useEntityData, useCreateEntity, useDeleteEntity, useFetchEntity, useFetchEntityByForeignId, useFetchEntityByShortId, useFetchManyEntities, useIncrementEntityViews, useFetchManyEntitiesWrapper, useUpdateEntity, type UseFetchManyEntitiesWrapperProps, type UseFetchManyEntitiesWrapperValues, } from "./hooks/entities";
|
|
17
17
|
export { useEntityList, useEntityListActions, type UseEntityListProps, type UseEntityListValues, type EntityListFilters, type EntityListSort, type EntityListFetchOptions, } from "./hooks/entity-lists";
|
|
18
18
|
export { useSpace, useSpaceData, useFetchSpace, useFetchSpaceByShortId, useFetchSpaceBySlug, useFetchSpaceBreadcrumb, useFetchSpaceChildren, useFetchManySpaces, useCheckSlugAvailability, useCreateSpace, useUpdateSpace, useDeleteSpace, useJoinSpace, useLeaveSpace, useFetchSpaceMembers, useFetchMySpaces, useUpdateMemberRole, useApproveMember, useDeclineMember, useRemoveMember, useSpacePermissions, type UseSpaceDataProps, type UseSpaceDataValues, type CreateSpaceProps, type UpdateSpaceProps, } from "./hooks/spaces";
|
|
19
19
|
export { useSpaceList, useSpaceListActions, type UseSpaceListProps, type UseSpaceListValues, } from "./hooks/space-lists";
|
|
20
|
-
export { useCommentSection, useCommentSectionData, useCreateComment, useFetchManyComments, useFetchComment, useFetchCommentByForeignId, useReplies, useUpdateComment,
|
|
20
|
+
export { useCommentSection, useCommentSectionData, useCreateComment, useFetchManyComments, useFetchComment, useFetchCommentByForeignId, useReplies, useUpdateComment, useDeleteComment, useEntityComments, useFetchManyCommentsWrapper, type UseFetchManyCommentsWrapperProps, type UseFetchManyCommentsWrapperValues, } from "./hooks/comments";
|
|
21
|
+
export { useFetchEntityReactions, useFetchCommentReactions, useFetchEntityReactionsWrapper, useFetchCommentReactionsWrapper, useAddReaction, useRemoveReaction, useReactionToggle, type UseFetchEntityReactionsWrapperProps, type UseFetchEntityReactionsWrapperValues, type UseFetchCommentReactionsWrapperProps, type UseFetchCommentReactionsWrapperValues, type UseReactionToggleValues, } from "./hooks/reactions";
|
|
21
22
|
export { useFetchUser, useFetchUserByForeignId, useFetchUserByUsername, useCheckUsernameAvailability, useFetchUserSuggestions, useMentions, useUpdateUser, } from "./hooks/users";
|
|
22
23
|
export { useFetchFollowStatus, useFetchFollowers, useFetchFollowersByUserId, useFetchFollowersCount, useFetchFollowersCountByUserId, useFetchFollowing, useFetchFollowingByUserId, useFetchFollowingCount, useFetchFollowingCountByUserId, useFollowManager, useFollowUser, useUnfollowByFollowId, useUnfollowUserByUserId, } from "./hooks/relationships/follows";
|
|
23
24
|
export { useRequestConnection, useAcceptConnection, useDeclineConnection, useRemoveConnection, useFetchConnections, useFetchConnectionStatus, useRemoveConnectionByUserId, useFetchConnectionsCount, useFetchSentPendingConnections, useFetchReceivedPendingConnections, useFetchConnectionsByUserId, useFetchConnectionsCountByUserId, useConnectionManager, } from "./hooks/relationships/connections";
|
|
@@ -34,6 +35,7 @@ export * as AppNotification from "./interfaces/models/AppNotification";
|
|
|
34
35
|
export type { Entity, EntityInclude, EntityIncludeArray, EntityIncludeParam, } from "./interfaces/models/Entity";
|
|
35
36
|
export type { Collection } from "./interfaces/models/Collection";
|
|
36
37
|
export type { Comment, GifData, CommentInclude, CommentIncludeArray, CommentIncludeParam, } from "./interfaces/models/Comment";
|
|
38
|
+
export type { Reaction, ReactionType, ReactionCounts, } from "./interfaces/models/Reaction";
|
|
37
39
|
export type { Mention } from "./interfaces/models/Mention";
|
|
38
40
|
export type { Space, SpaceDetailed, SpacePreview, SpaceMemberPermissions, ReadingPermission, PostingPermission, PaginationMeta, MySpaceItem, MySpacesResponse, JoinSpaceResponse, LeaveSpaceResponse, UpdateMemberRoleResponse, ApproveMemberResponse, DeclineMemberResponse, DeleteSpaceResponse, } from "./interfaces/models/Space";
|
|
39
41
|
export type { SpaceMember, SpaceMemberRole, SpaceMemberStatus, SpaceMemberWithUser, SpaceMembersResponse, } from "./interfaces/models/SpaceMember";
|
package/dist/esm/index.js
CHANGED
|
@@ -22,7 +22,7 @@ export { useAppNotifications, useAppNotificationsActions, } from "./hooks/app-no
|
|
|
22
22
|
// -- collections
|
|
23
23
|
export { useCollections, useCollectionsActions, useIsEntityInCollection, useCollectionEntitiesWrapper, } from "./hooks/collections";
|
|
24
24
|
// -- entities
|
|
25
|
-
export { useEntity, useEntityData, useCreateEntity, useDeleteEntity,
|
|
25
|
+
export { useEntity, useEntityData, useCreateEntity, useDeleteEntity, useFetchEntity, useFetchEntityByForeignId, useFetchEntityByShortId, useFetchManyEntities, useIncrementEntityViews, useFetchManyEntitiesWrapper, useUpdateEntity, } from "./hooks/entities";
|
|
26
26
|
// -- entity lists
|
|
27
27
|
export { useEntityList, useEntityListActions, } from "./hooks/entity-lists";
|
|
28
28
|
// -- spaces
|
|
@@ -30,7 +30,9 @@ export { useSpace, useSpaceData, useFetchSpace, useFetchSpaceByShortId, useFetch
|
|
|
30
30
|
// -- space lists
|
|
31
31
|
export { useSpaceList, useSpaceListActions, } from "./hooks/space-lists";
|
|
32
32
|
// -- comments
|
|
33
|
-
export { useCommentSection, useCommentSectionData, useCreateComment, useFetchManyComments, useFetchComment, useFetchCommentByForeignId, useReplies, useUpdateComment,
|
|
33
|
+
export { useCommentSection, useCommentSectionData, useCreateComment, useFetchManyComments, useFetchComment, useFetchCommentByForeignId, useReplies, useUpdateComment, useDeleteComment, useEntityComments, useFetchManyCommentsWrapper, } from "./hooks/comments";
|
|
34
|
+
// -- reactions
|
|
35
|
+
export { useFetchEntityReactions, useFetchCommentReactions, useFetchEntityReactionsWrapper, useFetchCommentReactionsWrapper, useAddReaction, useRemoveReaction, useReactionToggle, } from "./hooks/reactions";
|
|
34
36
|
// -- users
|
|
35
37
|
export { useFetchUser, useFetchUserByForeignId, useFetchUserByUsername, useCheckUsernameAvailability, useFetchUserSuggestions, useMentions, useUpdateUser, } from "./hooks/users";
|
|
36
38
|
// -- follows
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,SAAS,GACV,MAAM,aAAa,CAAC;AAErB,YAAY;AACZ,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D,+CAA+C;AAC/C,OAAO,EACL,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAE9D,YAAY;AACZ,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,oBAAoB;AACpB,OAAO,EAAE,OAAO,EAAsB,MAAM,cAAc,CAAC;AAE3D,oBAAoB;AACpB,OAAO,EACL,OAAO,EACP,cAAc,GAGf,MAAM,cAAc,CAAC;AAEtB,uBAAuB;AACvB,OAAO,EACL,mBAAmB,EACnB,0BAA0B,GAG3B,MAAM,2BAA2B,CAAC;AAEnC,iBAAiB;AACjB,OAAO,EACL,cAAc,EACd,qBAAqB,EACrB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AiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,8BAA8B,EAC9B,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,+BAA+B,CAAC;AAEvC,iBAAiB;AACjB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,8BAA8B,EAC9B,kCAAkC,EAClC,2BAA2B,EAC3B,gCAAgC,EAChC,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAE3C,aAAa;AACb,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE9D,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,aAAa;AACb,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAchD,OAAO,KAAK,eAAe,MAAM,qCAAqC,CAAC;AAwDvE,OAAO,EACL,cAAc,EACd,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,sCAAsC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Entity } from "./Entity";
|
|
2
2
|
import { Mention } from "./Mention";
|
|
3
3
|
import { User } from "./User";
|
|
4
|
+
import { ReactionCounts, ReactionType } from "./Reaction";
|
|
4
5
|
export interface GifData {
|
|
5
6
|
id: string;
|
|
6
7
|
url: string;
|
|
@@ -24,6 +25,8 @@ export interface Comment {
|
|
|
24
25
|
mentions: Mention[];
|
|
25
26
|
upvotes: string[];
|
|
26
27
|
downvotes: string[];
|
|
28
|
+
reactionCounts: ReactionCounts;
|
|
29
|
+
userReaction?: ReactionType | null;
|
|
27
30
|
repliesCount: number;
|
|
28
31
|
metadata: Record<string, any>;
|
|
29
32
|
createdAt: Date;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Mention } from "./Mention";
|
|
2
2
|
import { User } from "./User";
|
|
3
3
|
import { Space } from "./Space";
|
|
4
|
+
import { ReactionCounts, ReactionType } from "./Reaction";
|
|
4
5
|
export interface TopComment {
|
|
5
6
|
id: string;
|
|
6
7
|
user: User;
|
|
@@ -24,6 +25,8 @@ export interface Entity {
|
|
|
24
25
|
keywords: string[];
|
|
25
26
|
upvotes: string[];
|
|
26
27
|
downvotes: string[];
|
|
28
|
+
reactionCounts: ReactionCounts;
|
|
29
|
+
userReaction?: ReactionType | null;
|
|
27
30
|
repliesCount: number;
|
|
28
31
|
views: number;
|
|
29
32
|
score: number;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { User } from "./User";
|
|
2
|
+
export type ReactionType = "upvote" | "downvote" | "like" | "love" | "wow" | "sad" | "angry" | "funny";
|
|
3
|
+
export interface ReactionCounts {
|
|
4
|
+
upvote: number;
|
|
5
|
+
downvote: number;
|
|
6
|
+
like: number;
|
|
7
|
+
love: number;
|
|
8
|
+
wow: number;
|
|
9
|
+
sad: number;
|
|
10
|
+
angry: number;
|
|
11
|
+
funny: number;
|
|
12
|
+
}
|
|
13
|
+
export interface Reaction {
|
|
14
|
+
id: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
targetType: "Entity" | "Comment";
|
|
17
|
+
targetId: string;
|
|
18
|
+
userId: string;
|
|
19
|
+
reactionType: ReactionType;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
user?: User;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Reaction.js","sourceRoot":"","sources":["../../../../src/interfaces/models/Reaction.ts"],"names":[],"mappings":""}
|
|
@@ -164,6 +164,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
164
164
|
keywords: string[];
|
|
165
165
|
upvotes: string[];
|
|
166
166
|
downvotes: string[];
|
|
167
|
+
reactionCounts: {
|
|
168
|
+
upvote: number;
|
|
169
|
+
downvote: number;
|
|
170
|
+
like: number;
|
|
171
|
+
love: number;
|
|
172
|
+
wow: number;
|
|
173
|
+
sad: number;
|
|
174
|
+
angry: number;
|
|
175
|
+
funny: number;
|
|
176
|
+
};
|
|
177
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
167
178
|
repliesCount: number;
|
|
168
179
|
views: number;
|
|
169
180
|
score: number;
|
|
@@ -327,6 +338,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
327
338
|
keywords: string[];
|
|
328
339
|
upvotes: string[];
|
|
329
340
|
downvotes: string[];
|
|
341
|
+
reactionCounts: {
|
|
342
|
+
upvote: number;
|
|
343
|
+
downvote: number;
|
|
344
|
+
like: number;
|
|
345
|
+
love: number;
|
|
346
|
+
wow: number;
|
|
347
|
+
sad: number;
|
|
348
|
+
angry: number;
|
|
349
|
+
funny: number;
|
|
350
|
+
};
|
|
351
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
330
352
|
repliesCount: number;
|
|
331
353
|
views: number;
|
|
332
354
|
score: number;
|
|
@@ -490,6 +512,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
490
512
|
keywords: string[];
|
|
491
513
|
upvotes: string[];
|
|
492
514
|
downvotes: string[];
|
|
515
|
+
reactionCounts: {
|
|
516
|
+
upvote: number;
|
|
517
|
+
downvote: number;
|
|
518
|
+
like: number;
|
|
519
|
+
love: number;
|
|
520
|
+
wow: number;
|
|
521
|
+
sad: number;
|
|
522
|
+
angry: number;
|
|
523
|
+
funny: number;
|
|
524
|
+
};
|
|
525
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
493
526
|
repliesCount: number;
|
|
494
527
|
views: number;
|
|
495
528
|
score: number;
|
|
@@ -656,6 +689,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
656
689
|
keywords: string[];
|
|
657
690
|
upvotes: string[];
|
|
658
691
|
downvotes: string[];
|
|
692
|
+
reactionCounts: {
|
|
693
|
+
upvote: number;
|
|
694
|
+
downvote: number;
|
|
695
|
+
like: number;
|
|
696
|
+
love: number;
|
|
697
|
+
wow: number;
|
|
698
|
+
sad: number;
|
|
699
|
+
angry: number;
|
|
700
|
+
funny: number;
|
|
701
|
+
};
|
|
702
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
659
703
|
repliesCount: number;
|
|
660
704
|
views: number;
|
|
661
705
|
score: number;
|
|
@@ -819,6 +863,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
819
863
|
keywords: string[];
|
|
820
864
|
upvotes: string[];
|
|
821
865
|
downvotes: string[];
|
|
866
|
+
reactionCounts: {
|
|
867
|
+
upvote: number;
|
|
868
|
+
downvote: number;
|
|
869
|
+
like: number;
|
|
870
|
+
love: number;
|
|
871
|
+
wow: number;
|
|
872
|
+
sad: number;
|
|
873
|
+
angry: number;
|
|
874
|
+
funny: number;
|
|
875
|
+
};
|
|
876
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
822
877
|
repliesCount: number;
|
|
823
878
|
views: number;
|
|
824
879
|
score: number;
|
|
@@ -982,6 +1037,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
982
1037
|
keywords: string[];
|
|
983
1038
|
upvotes: string[];
|
|
984
1039
|
downvotes: string[];
|
|
1040
|
+
reactionCounts: {
|
|
1041
|
+
upvote: number;
|
|
1042
|
+
downvote: number;
|
|
1043
|
+
like: number;
|
|
1044
|
+
love: number;
|
|
1045
|
+
wow: number;
|
|
1046
|
+
sad: number;
|
|
1047
|
+
angry: number;
|
|
1048
|
+
funny: number;
|
|
1049
|
+
};
|
|
1050
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
985
1051
|
repliesCount: number;
|
|
986
1052
|
views: number;
|
|
987
1053
|
score: number;
|
|
@@ -1148,6 +1214,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
1148
1214
|
keywords: string[];
|
|
1149
1215
|
upvotes: string[];
|
|
1150
1216
|
downvotes: string[];
|
|
1217
|
+
reactionCounts: {
|
|
1218
|
+
upvote: number;
|
|
1219
|
+
downvote: number;
|
|
1220
|
+
like: number;
|
|
1221
|
+
love: number;
|
|
1222
|
+
wow: number;
|
|
1223
|
+
sad: number;
|
|
1224
|
+
angry: number;
|
|
1225
|
+
funny: number;
|
|
1226
|
+
};
|
|
1227
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
1151
1228
|
repliesCount: number;
|
|
1152
1229
|
views: number;
|
|
1153
1230
|
score: number;
|
|
@@ -1314,6 +1391,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
1314
1391
|
keywords: string[];
|
|
1315
1392
|
upvotes: string[];
|
|
1316
1393
|
downvotes: string[];
|
|
1394
|
+
reactionCounts: {
|
|
1395
|
+
upvote: number;
|
|
1396
|
+
downvote: number;
|
|
1397
|
+
like: number;
|
|
1398
|
+
love: number;
|
|
1399
|
+
wow: number;
|
|
1400
|
+
sad: number;
|
|
1401
|
+
angry: number;
|
|
1402
|
+
funny: number;
|
|
1403
|
+
};
|
|
1404
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
1317
1405
|
repliesCount: number;
|
|
1318
1406
|
views: number;
|
|
1319
1407
|
score: number;
|
|
@@ -1477,6 +1565,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
1477
1565
|
keywords: string[];
|
|
1478
1566
|
upvotes: string[];
|
|
1479
1567
|
downvotes: string[];
|
|
1568
|
+
reactionCounts: {
|
|
1569
|
+
upvote: number;
|
|
1570
|
+
downvote: number;
|
|
1571
|
+
like: number;
|
|
1572
|
+
love: number;
|
|
1573
|
+
wow: number;
|
|
1574
|
+
sad: number;
|
|
1575
|
+
angry: number;
|
|
1576
|
+
funny: number;
|
|
1577
|
+
};
|
|
1578
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
1480
1579
|
repliesCount: number;
|
|
1481
1580
|
views: number;
|
|
1482
1581
|
score: number;
|
|
@@ -1640,6 +1739,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
1640
1739
|
keywords: string[];
|
|
1641
1740
|
upvotes: string[];
|
|
1642
1741
|
downvotes: string[];
|
|
1742
|
+
reactionCounts: {
|
|
1743
|
+
upvote: number;
|
|
1744
|
+
downvote: number;
|
|
1745
|
+
like: number;
|
|
1746
|
+
love: number;
|
|
1747
|
+
wow: number;
|
|
1748
|
+
sad: number;
|
|
1749
|
+
angry: number;
|
|
1750
|
+
funny: number;
|
|
1751
|
+
};
|
|
1752
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
1643
1753
|
repliesCount: number;
|
|
1644
1754
|
views: number;
|
|
1645
1755
|
score: number;
|
|
@@ -1803,6 +1913,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
1803
1913
|
keywords: string[];
|
|
1804
1914
|
upvotes: string[];
|
|
1805
1915
|
downvotes: string[];
|
|
1916
|
+
reactionCounts: {
|
|
1917
|
+
upvote: number;
|
|
1918
|
+
downvote: number;
|
|
1919
|
+
like: number;
|
|
1920
|
+
love: number;
|
|
1921
|
+
wow: number;
|
|
1922
|
+
sad: number;
|
|
1923
|
+
angry: number;
|
|
1924
|
+
funny: number;
|
|
1925
|
+
};
|
|
1926
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
1806
1927
|
repliesCount: number;
|
|
1807
1928
|
views: number;
|
|
1808
1929
|
score: number;
|
|
@@ -1966,6 +2087,17 @@ export declare const entityListsSlice: import("@reduxjs/toolkit").Slice<EntityLi
|
|
|
1966
2087
|
keywords: string[];
|
|
1967
2088
|
upvotes: string[];
|
|
1968
2089
|
downvotes: string[];
|
|
2090
|
+
reactionCounts: {
|
|
2091
|
+
upvote: number;
|
|
2092
|
+
downvote: number;
|
|
2093
|
+
like: number;
|
|
2094
|
+
love: number;
|
|
2095
|
+
wow: number;
|
|
2096
|
+
sad: number;
|
|
2097
|
+
angry: number;
|
|
2098
|
+
funny: number;
|
|
2099
|
+
};
|
|
2100
|
+
userReaction?: (import("../..").ReactionType | null) | undefined;
|
|
1969
2101
|
repliesCount: number;
|
|
1970
2102
|
views: number;
|
|
1971
2103
|
score: number;
|
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Comment } from "../../interfaces/models/Comment";
|
|
2
|
-
declare function useCommentVotes(props: {
|
|
3
|
-
comment: Comment;
|
|
4
|
-
setComment: React.Dispatch<React.SetStateAction<Comment>>;
|
|
5
|
-
}): {
|
|
6
|
-
userUpvotedComment: boolean;
|
|
7
|
-
userDownvotedComment: boolean;
|
|
8
|
-
upvoteComment: () => Promise<void>;
|
|
9
|
-
removeCommentUpvote: () => Promise<void>;
|
|
10
|
-
downvoteComment: () => Promise<void>;
|
|
11
|
-
removeCommentDownvote: () => Promise<void>;
|
|
12
|
-
};
|
|
13
|
-
export default useCommentVotes;
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
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);
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
-
if (ar || !(i in from)) {
|
|
52
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
-
ar[i] = from[i];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
-
};
|
|
58
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
59
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
-
var react_1 = require("react");
|
|
63
|
-
var handleError_1 = require("../../utils/handleError");
|
|
64
|
-
var user_1 = require("../user");
|
|
65
|
-
// Import the communication hooks
|
|
66
|
-
var useUpvoteComment_1 = __importDefault(require("./useUpvoteComment"));
|
|
67
|
-
var useRemoveCommentUpvote_1 = __importDefault(require("./useRemoveCommentUpvote"));
|
|
68
|
-
var useDownvoteComment_1 = __importDefault(require("./useDownvoteComment"));
|
|
69
|
-
var useRemoveCommentDownvote_1 = __importDefault(require("./useRemoveCommentDownvote"));
|
|
70
|
-
function useCommentVotes(props) {
|
|
71
|
-
var _this = this;
|
|
72
|
-
var user = (0, user_1.useUser)().user;
|
|
73
|
-
var comment = props.comment, setComment = props.setComment;
|
|
74
|
-
// Save the previous state in case we need to revert
|
|
75
|
-
var _a = (0, react_1.useState)(comment), previousComment = _a[0], setPreviousComment = _a[1];
|
|
76
|
-
var _b = (0, react_1.useState)(false), isUpdating = _b[0], setIsUpdating = _b[1];
|
|
77
|
-
// Compute current user's vote state
|
|
78
|
-
var userUpvotedComment = !!((user === null || user === void 0 ? void 0 : user.id) &&
|
|
79
|
-
comment.upvotes.includes(user.id));
|
|
80
|
-
var userDownvotedComment = !!((user === null || user === void 0 ? void 0 : user.id) &&
|
|
81
|
-
comment.downvotes.includes(user.id));
|
|
82
|
-
// Helper to update state and remember the previous value
|
|
83
|
-
var updateCommentState = function (newCommentState) {
|
|
84
|
-
setPreviousComment(comment);
|
|
85
|
-
setComment(newCommentState);
|
|
86
|
-
};
|
|
87
|
-
var revertToPreviousState = (0, react_1.useCallback)(function () {
|
|
88
|
-
setComment(previousComment);
|
|
89
|
-
}, [previousComment, setComment]);
|
|
90
|
-
// Get our request functions from the extracted hooks
|
|
91
|
-
var upvoteCommentRequest = (0, useUpvoteComment_1.default)();
|
|
92
|
-
var removeUpvoteRequest = (0, useRemoveCommentUpvote_1.default)();
|
|
93
|
-
var downvoteCommentRequest = (0, useDownvoteComment_1.default)();
|
|
94
|
-
var removeDownvoteRequest = (0, useRemoveCommentDownvote_1.default)();
|
|
95
|
-
var handleUpvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
-
var updatedComment, err_1;
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0:
|
|
100
|
-
if (!user)
|
|
101
|
-
throw new Error("No authenticated user");
|
|
102
|
-
if (isUpdating)
|
|
103
|
-
return [2 /*return*/];
|
|
104
|
-
// Optimistic update: add upvote and remove any downvote from the user
|
|
105
|
-
updateCommentState(__assign(__assign({}, comment), { upvotes: __spreadArray(__spreadArray([], comment.upvotes, true), [user.id], false), downvotes: comment.downvotes.filter(function (id) { return id !== user.id; }) }));
|
|
106
|
-
setIsUpdating(true);
|
|
107
|
-
_a.label = 1;
|
|
108
|
-
case 1:
|
|
109
|
-
_a.trys.push([1, 3, 4, 5]);
|
|
110
|
-
return [4 /*yield*/, upvoteCommentRequest({
|
|
111
|
-
commentId: comment.id,
|
|
112
|
-
})];
|
|
113
|
-
case 2:
|
|
114
|
-
updatedComment = _a.sent();
|
|
115
|
-
setComment(updatedComment);
|
|
116
|
-
return [3 /*break*/, 5];
|
|
117
|
-
case 3:
|
|
118
|
-
err_1 = _a.sent();
|
|
119
|
-
revertToPreviousState();
|
|
120
|
-
(0, handleError_1.handleError)(err_1, "Failed to update comment vote: ");
|
|
121
|
-
return [3 /*break*/, 5];
|
|
122
|
-
case 4:
|
|
123
|
-
setIsUpdating(false);
|
|
124
|
-
return [7 /*endfinally*/];
|
|
125
|
-
case 5: return [2 /*return*/];
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}); };
|
|
129
|
-
var handleRemoveUpvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
130
|
-
var updatedComment, err_2;
|
|
131
|
-
return __generator(this, function (_a) {
|
|
132
|
-
switch (_a.label) {
|
|
133
|
-
case 0:
|
|
134
|
-
if (!user)
|
|
135
|
-
throw new Error("No authenticated user");
|
|
136
|
-
if (isUpdating)
|
|
137
|
-
return [2 /*return*/];
|
|
138
|
-
// Optimistic update: remove the user's upvote
|
|
139
|
-
updateCommentState(__assign(__assign({}, comment), { upvotes: comment.upvotes.filter(function (id) { return id !== user.id; }) }));
|
|
140
|
-
setIsUpdating(true);
|
|
141
|
-
_a.label = 1;
|
|
142
|
-
case 1:
|
|
143
|
-
_a.trys.push([1, 3, 4, 5]);
|
|
144
|
-
return [4 /*yield*/, removeUpvoteRequest({
|
|
145
|
-
commentId: comment.id,
|
|
146
|
-
})];
|
|
147
|
-
case 2:
|
|
148
|
-
updatedComment = _a.sent();
|
|
149
|
-
setComment(updatedComment);
|
|
150
|
-
return [3 /*break*/, 5];
|
|
151
|
-
case 3:
|
|
152
|
-
err_2 = _a.sent();
|
|
153
|
-
revertToPreviousState();
|
|
154
|
-
(0, handleError_1.handleError)(err_2, "Failed to remove upvote from comment: ");
|
|
155
|
-
return [3 /*break*/, 5];
|
|
156
|
-
case 4:
|
|
157
|
-
setIsUpdating(false);
|
|
158
|
-
return [7 /*endfinally*/];
|
|
159
|
-
case 5: return [2 /*return*/];
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}); };
|
|
163
|
-
var handleDownvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
164
|
-
var updatedComment, err_3;
|
|
165
|
-
return __generator(this, function (_a) {
|
|
166
|
-
switch (_a.label) {
|
|
167
|
-
case 0:
|
|
168
|
-
if (!user)
|
|
169
|
-
throw new Error("No authenticated user");
|
|
170
|
-
if (isUpdating)
|
|
171
|
-
return [2 /*return*/];
|
|
172
|
-
// Optimistic update: add downvote and remove any upvote from the user
|
|
173
|
-
updateCommentState(__assign(__assign({}, comment), { downvotes: __spreadArray(__spreadArray([], comment.downvotes, true), [user.id], false), upvotes: comment.upvotes.filter(function (id) { return id !== user.id; }) }));
|
|
174
|
-
setIsUpdating(true);
|
|
175
|
-
_a.label = 1;
|
|
176
|
-
case 1:
|
|
177
|
-
_a.trys.push([1, 3, 4, 5]);
|
|
178
|
-
return [4 /*yield*/, downvoteCommentRequest({
|
|
179
|
-
commentId: comment.id,
|
|
180
|
-
})];
|
|
181
|
-
case 2:
|
|
182
|
-
updatedComment = _a.sent();
|
|
183
|
-
setComment(updatedComment);
|
|
184
|
-
return [3 /*break*/, 5];
|
|
185
|
-
case 3:
|
|
186
|
-
err_3 = _a.sent();
|
|
187
|
-
revertToPreviousState();
|
|
188
|
-
(0, handleError_1.handleError)(err_3, "Failed to update comment vote: ");
|
|
189
|
-
return [3 /*break*/, 5];
|
|
190
|
-
case 4:
|
|
191
|
-
setIsUpdating(false);
|
|
192
|
-
return [7 /*endfinally*/];
|
|
193
|
-
case 5: return [2 /*return*/];
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
}); };
|
|
197
|
-
var handleRemoveDownvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
198
|
-
var updatedComment, err_4;
|
|
199
|
-
return __generator(this, function (_a) {
|
|
200
|
-
switch (_a.label) {
|
|
201
|
-
case 0:
|
|
202
|
-
if (!user)
|
|
203
|
-
throw new Error("No authenticated user");
|
|
204
|
-
if (isUpdating)
|
|
205
|
-
return [2 /*return*/];
|
|
206
|
-
// Optimistic update: remove the user's downvote
|
|
207
|
-
updateCommentState(__assign(__assign({}, comment), { downvotes: comment.downvotes.filter(function (id) { return id !== user.id; }) }));
|
|
208
|
-
setIsUpdating(true);
|
|
209
|
-
_a.label = 1;
|
|
210
|
-
case 1:
|
|
211
|
-
_a.trys.push([1, 3, 4, 5]);
|
|
212
|
-
return [4 /*yield*/, removeDownvoteRequest({
|
|
213
|
-
commentId: comment.id,
|
|
214
|
-
})];
|
|
215
|
-
case 2:
|
|
216
|
-
updatedComment = _a.sent();
|
|
217
|
-
setComment(updatedComment);
|
|
218
|
-
return [3 /*break*/, 5];
|
|
219
|
-
case 3:
|
|
220
|
-
err_4 = _a.sent();
|
|
221
|
-
revertToPreviousState();
|
|
222
|
-
(0, handleError_1.handleError)(err_4, "Failed to remove downvote from comment: ");
|
|
223
|
-
return [3 /*break*/, 5];
|
|
224
|
-
case 4:
|
|
225
|
-
setIsUpdating(false);
|
|
226
|
-
return [7 /*endfinally*/];
|
|
227
|
-
case 5: return [2 /*return*/];
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}); };
|
|
231
|
-
return {
|
|
232
|
-
userUpvotedComment: userUpvotedComment,
|
|
233
|
-
userDownvotedComment: userDownvotedComment,
|
|
234
|
-
upvoteComment: handleUpvote,
|
|
235
|
-
removeCommentUpvote: handleRemoveUpvote,
|
|
236
|
-
downvoteComment: handleDownvote,
|
|
237
|
-
removeCommentDownvote: handleRemoveDownvote,
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
exports.default = useCommentVotes;
|
|
241
|
-
//# sourceMappingURL=useCommentVotes.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCommentVotes.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useCommentVotes.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8C;AAC9C,uDAAsD;AAEtD,gCAAkC;AAElC,iCAAiC;AACjC,wEAAkD;AAClD,oFAA8D;AAC9D,4EAAsD;AACtD,wFAAkE;AAElE,SAAS,eAAe,CAAC,KAGxB;IAHD,iBAgJC;IA5IS,IAAA,IAAI,GAAK,IAAA,cAAO,GAAE,KAAd,CAAe;IACnB,IAAA,OAAO,GAAiB,KAAK,QAAtB,EAAE,UAAU,GAAK,KAAK,WAAV,CAAW;IAEtC,oDAAoD;IAC9C,IAAA,KAAwC,IAAA,gBAAQ,EAAU,OAAO,CAAC,EAAjE,eAAe,QAAA,EAAE,kBAAkB,QAA8B,CAAC;IACnE,IAAA,KAA8B,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAA5C,UAAU,QAAA,EAAE,aAAa,QAAmB,CAAC;IAEpD,oCAAoC;IACpC,IAAM,kBAAkB,GAAG,CAAC,CAAC,CAC3B,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,EAAE;QACR,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAClC,CAAC;IAEF,IAAM,oBAAoB,GAAG,CAAC,CAAC,CAC7B,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,EAAE;QACR,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CACpC,CAAC;IAEF,yDAAyD;IACzD,IAAM,kBAAkB,GAAG,UAAC,eAAwB;QAClD,kBAA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C,IAAM,KAAK,GAAG,IAAA,yBAAe,GAAE,CAAC;IACxB,IAAA,SAAS,GAAK,IAAA,oBAAU,GAAE,UAAjB,CAAkB;IAEnC,IAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,gEAAO,EAAoC;;YAAlC,SAAS,eAAA;;;;oBAChB,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACD,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACgB,qBAAM,KAAK,CAAC,KAAK,CAChC,WAAI,SAAS,uBAAa,SAAS,cAAW,CAC/C,EAAA;;oBAFK,QAAQ,GAAG,SAEhB;oBACD,sBAAO,QAAQ,CAAC,IAAe,EAAC;;;SACjC,EACD,CAAC,KAAK,EAAE,SAAS,CAAC,CACnB,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,kBAAe,kBAAkB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRemoveCommentDownvote.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useRemoveCommentDownvote.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAoC;AACpC,iFAA2D;AAC3D,sEAAgD;AAGhD,SAAS,wBAAwB;IAAjC,iBAqBC;IApBC,IAAM,KAAK,GAAG,IAAA,yBAAe,GAAE,CAAC;IACxB,IAAA,SAAS,GAAK,IAAA,oBAAU,GAAE,UAAjB,CAAkB;IAEnC,IAAM,qBAAqB,GAAG,IAAA,mBAAW,EACvC,gEAAO,EAAoC;;YAAlC,SAAS,eAAA;;;;oBAChB,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACD,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACgB,qBAAM,KAAK,CAAC,KAAK,CAChC,WAAI,SAAS,uBAAa,SAAS,qBAAkB,CACtD,EAAA;;oBAFK,QAAQ,GAAG,SAEhB;oBACD,sBAAO,QAAQ,CAAC,IAAe,EAAC;;;SACjC,EACD,CAAC,KAAK,EAAE,SAAS,CAAC,CACnB,CAAC;IAEF,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,kBAAe,wBAAwB,CAAC"}
|