@replyke/core 4.0.4 → 4.0.5
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/useCommentVotes.d.ts +4 -4
- package/dist/cjs/hooks/comments/useCommentVotes.js +132 -55
- package/dist/cjs/hooks/comments/useCommentVotes.js.map +1 -1
- package/dist/cjs/hooks/comments/useDownvoteComment.d.ts +4 -0
- package/dist/cjs/hooks/comments/useDownvoteComment.js +73 -0
- package/dist/cjs/hooks/comments/useDownvoteComment.js.map +1 -0
- package/dist/cjs/hooks/comments/useRemoveCommentDownvote.d.ts +4 -0
- package/dist/cjs/hooks/comments/useRemoveCommentDownvote.js +73 -0
- package/dist/cjs/hooks/comments/useRemoveCommentDownvote.js.map +1 -0
- package/dist/cjs/hooks/comments/useRemoveCommentUpvote.d.ts +4 -0
- package/dist/cjs/hooks/comments/useRemoveCommentUpvote.js +73 -0
- package/dist/cjs/hooks/comments/useRemoveCommentUpvote.js.map +1 -0
- package/dist/cjs/hooks/comments/useUpvoteComment.d.ts +4 -0
- package/dist/cjs/hooks/comments/useUpvoteComment.js +73 -0
- package/dist/cjs/hooks/comments/useUpvoteComment.js.map +1 -0
- package/dist/cjs/hooks/entities/useDownvoteEntity.d.ts +4 -0
- package/dist/cjs/hooks/entities/useDownvoteEntity.js +73 -0
- package/dist/cjs/hooks/entities/useDownvoteEntity.js.map +1 -0
- package/dist/cjs/hooks/entities/useEntityVotes.d.ts +4 -4
- package/dist/cjs/hooks/entities/useEntityVotes.js +138 -57
- package/dist/cjs/hooks/entities/useEntityVotes.js.map +1 -1
- package/dist/cjs/hooks/entities/useRemoveEntityDownvote.d.ts +4 -0
- package/dist/cjs/hooks/entities/useRemoveEntityDownvote.js +73 -0
- package/dist/cjs/hooks/entities/useRemoveEntityDownvote.js.map +1 -0
- package/dist/cjs/hooks/entities/useRemoveEntityUpvote.d.ts +4 -0
- package/dist/cjs/hooks/entities/useRemoveEntityUpvote.js +73 -0
- package/dist/cjs/hooks/entities/useRemoveEntityUpvote.js.map +1 -0
- package/dist/cjs/hooks/entities/useUpvoteEntity.d.ts +4 -0
- package/dist/cjs/hooks/entities/useUpvoteEntity.js +73 -0
- package/dist/cjs/hooks/entities/useUpvoteEntity.js.map +1 -0
- package/dist/cjs/utils/handleError.d.ts +1 -1
- package/dist/cjs/utils/handleError.js +8 -5
- package/dist/cjs/utils/handleError.js.map +1 -1
- package/dist/esm/hooks/comments/useCommentVotes.d.ts +4 -4
- package/dist/esm/hooks/comments/useCommentVotes.js +132 -55
- package/dist/esm/hooks/comments/useCommentVotes.js.map +1 -1
- package/dist/esm/hooks/comments/useDownvoteComment.d.ts +4 -0
- package/dist/esm/hooks/comments/useDownvoteComment.js +68 -0
- package/dist/esm/hooks/comments/useDownvoteComment.js.map +1 -0
- package/dist/esm/hooks/comments/useRemoveCommentDownvote.d.ts +4 -0
- package/dist/esm/hooks/comments/useRemoveCommentDownvote.js +68 -0
- package/dist/esm/hooks/comments/useRemoveCommentDownvote.js.map +1 -0
- package/dist/esm/hooks/comments/useRemoveCommentUpvote.d.ts +4 -0
- package/dist/esm/hooks/comments/useRemoveCommentUpvote.js +68 -0
- package/dist/esm/hooks/comments/useRemoveCommentUpvote.js.map +1 -0
- package/dist/esm/hooks/comments/useUpvoteComment.d.ts +4 -0
- package/dist/esm/hooks/comments/useUpvoteComment.js +68 -0
- package/dist/esm/hooks/comments/useUpvoteComment.js.map +1 -0
- package/dist/esm/hooks/entities/useDownvoteEntity.d.ts +4 -0
- package/dist/esm/hooks/entities/useDownvoteEntity.js +68 -0
- package/dist/esm/hooks/entities/useDownvoteEntity.js.map +1 -0
- package/dist/esm/hooks/entities/useEntityVotes.d.ts +4 -4
- package/dist/esm/hooks/entities/useEntityVotes.js +138 -57
- package/dist/esm/hooks/entities/useEntityVotes.js.map +1 -1
- package/dist/esm/hooks/entities/useRemoveEntityDownvote.d.ts +4 -0
- package/dist/esm/hooks/entities/useRemoveEntityDownvote.js +68 -0
- package/dist/esm/hooks/entities/useRemoveEntityDownvote.js.map +1 -0
- package/dist/esm/hooks/entities/useRemoveEntityUpvote.d.ts +4 -0
- package/dist/esm/hooks/entities/useRemoveEntityUpvote.js +68 -0
- package/dist/esm/hooks/entities/useRemoveEntityUpvote.js.map +1 -0
- package/dist/esm/hooks/entities/useUpvoteEntity.d.ts +4 -0
- package/dist/esm/hooks/entities/useUpvoteEntity.js +68 -0
- package/dist/esm/hooks/entities/useUpvoteEntity.js.map +1 -0
- package/dist/esm/utils/handleError.d.ts +1 -1
- package/dist/esm/utils/handleError.js +8 -5
- package/dist/esm/utils/handleError.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleError.js","sourceRoot":"","sources":["../../../src/utils/handleError.ts"],"names":[],"mappings":";;;AAAO,IAAM,WAAW,GAAG,UAAC,
|
|
1
|
+
{"version":3,"file":"handleError.js","sourceRoot":"","sources":["../../../src/utils/handleError.ts"],"names":[],"mappings":";;;AAAO,IAAM,WAAW,GAAG,UAAC,GAAQ,EAAE,WAAoB;IACxD,IAAI,QAAQ,GAAG,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC,CAAC;IACnC,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IACD,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,EAAE,CAAC;QACjB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AAVW,QAAA,WAAW,eAUtB"}
|
|
@@ -3,9 +3,9 @@ declare function useCommentVotes(props: {
|
|
|
3
3
|
comment: CommentType;
|
|
4
4
|
setComment: React.Dispatch<React.SetStateAction<CommentType>>;
|
|
5
5
|
}): {
|
|
6
|
-
upvoteComment: () => void
|
|
7
|
-
removeCommentUpvote: () => void
|
|
8
|
-
downvoteComment: () => void
|
|
9
|
-
removeCommentDownvote: () => void
|
|
6
|
+
upvoteComment: () => Promise<void>;
|
|
7
|
+
removeCommentUpvote: () => Promise<void>;
|
|
8
|
+
downvoteComment: () => Promise<void>;
|
|
9
|
+
removeCommentDownvote: () => Promise<void>;
|
|
10
10
|
};
|
|
11
11
|
export default useCommentVotes;
|
|
@@ -56,42 +56,53 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
56
56
|
};
|
|
57
57
|
import { useCallback, useState } from "react";
|
|
58
58
|
import { handleError } from "../../utils/handleError";
|
|
59
|
-
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
60
|
-
import useProject from "../projects/useProject";
|
|
61
59
|
import useUser from "../users/useUser";
|
|
60
|
+
// Import the communication hooks
|
|
61
|
+
import useUpvoteComment from "./useUpvoteComment";
|
|
62
|
+
import useRemoveCommentUpvote from "./useRemoveCommentUpvote";
|
|
63
|
+
import useDownvoteComment from "./useDownvoteComment";
|
|
64
|
+
import useRemoveCommentDownvote from "./useRemoveCommentDownvote";
|
|
62
65
|
function useCommentVotes(props) {
|
|
63
66
|
var _this = this;
|
|
64
|
-
var axios = useAxiosPrivate();
|
|
65
|
-
var projectId = useProject().projectId;
|
|
66
67
|
var user = useUser().user;
|
|
67
|
-
var basePath = projectId ? "/".concat(projectId, "/comments") : null;
|
|
68
68
|
var comment = props.comment, setComment = props.setComment;
|
|
69
|
-
|
|
70
|
-
var
|
|
69
|
+
// Save the previous state in case we need to revert
|
|
70
|
+
var _a = useState(comment), previousComment = _a[0], setPreviousComment = _a[1];
|
|
71
|
+
var _b = useState(false), isUpdating = _b[0], setIsUpdating = _b[1];
|
|
72
|
+
// Helper to update state and remember the previous value
|
|
71
73
|
var updateCommentState = function (newCommentState) {
|
|
72
|
-
setPreviousComment(comment);
|
|
74
|
+
setPreviousComment(comment);
|
|
73
75
|
setComment(newCommentState);
|
|
74
76
|
};
|
|
75
77
|
var revertToPreviousState = useCallback(function () {
|
|
76
78
|
setComment(previousComment);
|
|
77
|
-
}, [
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
}, [previousComment, setComment]);
|
|
80
|
+
// Get our request functions from the extracted hooks
|
|
81
|
+
var upvoteCommentRequest = useUpvoteComment();
|
|
82
|
+
var removeUpvoteRequest = useRemoveCommentUpvote();
|
|
83
|
+
var downvoteCommentRequest = useDownvoteComment();
|
|
84
|
+
var removeDownvoteRequest = useRemoveCommentDownvote();
|
|
85
|
+
var handleUpvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
86
|
+
var updatedComment, err_1;
|
|
80
87
|
return __generator(this, function (_a) {
|
|
81
88
|
switch (_a.label) {
|
|
82
89
|
case 0:
|
|
83
|
-
if (!
|
|
84
|
-
throw new Error("No
|
|
85
|
-
|
|
90
|
+
if (!user)
|
|
91
|
+
throw new Error("No authenticated user");
|
|
92
|
+
if (isUpdating)
|
|
93
|
+
return [2 /*return*/];
|
|
94
|
+
// Optimistic update: add upvote and remove any downvote from the user
|
|
95
|
+
updateCommentState(__assign(__assign({}, comment), { upvotes: __spreadArray(__spreadArray([], comment.upvotes, true), [user.id], false), downvotes: comment.downvotes.filter(function (id) { return id !== user.id; }) }));
|
|
86
96
|
setIsUpdating(true);
|
|
87
97
|
_a.label = 1;
|
|
88
98
|
case 1:
|
|
89
99
|
_a.trys.push([1, 3, 4, 5]);
|
|
90
|
-
|
|
91
|
-
|
|
100
|
+
return [4 /*yield*/, upvoteCommentRequest({
|
|
101
|
+
commentId: comment.id,
|
|
102
|
+
})];
|
|
92
103
|
case 2:
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
updatedComment = _a.sent();
|
|
105
|
+
setComment(updatedComment);
|
|
95
106
|
return [3 /*break*/, 5];
|
|
96
107
|
case 3:
|
|
97
108
|
err_1 = _a.sent();
|
|
@@ -104,43 +115,109 @@ function useCommentVotes(props) {
|
|
|
104
115
|
case 5: return [2 /*return*/];
|
|
105
116
|
}
|
|
106
117
|
});
|
|
107
|
-
}); }
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
118
|
+
}); };
|
|
119
|
+
var handleRemoveUpvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
120
|
+
var updatedComment, err_2;
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!user)
|
|
125
|
+
throw new Error("No authenticated user");
|
|
126
|
+
if (isUpdating)
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
// Optimistic update: remove the user's upvote
|
|
129
|
+
updateCommentState(__assign(__assign({}, comment), { upvotes: comment.upvotes.filter(function (id) { return id !== user.id; }) }));
|
|
130
|
+
setIsUpdating(true);
|
|
131
|
+
_a.label = 1;
|
|
132
|
+
case 1:
|
|
133
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
134
|
+
return [4 /*yield*/, removeUpvoteRequest({
|
|
135
|
+
commentId: comment.id,
|
|
136
|
+
})];
|
|
137
|
+
case 2:
|
|
138
|
+
updatedComment = _a.sent();
|
|
139
|
+
setComment(updatedComment);
|
|
140
|
+
return [3 /*break*/, 5];
|
|
141
|
+
case 3:
|
|
142
|
+
err_2 = _a.sent();
|
|
143
|
+
revertToPreviousState();
|
|
144
|
+
handleError(err_2, "Failed to remove upvote from comment: ");
|
|
145
|
+
return [3 /*break*/, 5];
|
|
146
|
+
case 4:
|
|
147
|
+
setIsUpdating(false);
|
|
148
|
+
return [7 /*endfinally*/];
|
|
149
|
+
case 5: return [2 /*return*/];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}); };
|
|
153
|
+
var handleDownvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
154
|
+
var updatedComment, err_3;
|
|
155
|
+
return __generator(this, function (_a) {
|
|
156
|
+
switch (_a.label) {
|
|
157
|
+
case 0:
|
|
158
|
+
if (!user)
|
|
159
|
+
throw new Error("No authenticated user");
|
|
160
|
+
if (isUpdating)
|
|
161
|
+
return [2 /*return*/];
|
|
162
|
+
// Optimistic update: add downvote and remove any upvote from the user
|
|
163
|
+
updateCommentState(__assign(__assign({}, comment), { downvotes: __spreadArray(__spreadArray([], comment.downvotes, true), [user.id], false), upvotes: comment.upvotes.filter(function (id) { return id !== user.id; }) }));
|
|
164
|
+
setIsUpdating(true);
|
|
165
|
+
_a.label = 1;
|
|
166
|
+
case 1:
|
|
167
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
168
|
+
return [4 /*yield*/, downvoteCommentRequest({
|
|
169
|
+
commentId: comment.id,
|
|
170
|
+
})];
|
|
171
|
+
case 2:
|
|
172
|
+
updatedComment = _a.sent();
|
|
173
|
+
setComment(updatedComment);
|
|
174
|
+
return [3 /*break*/, 5];
|
|
175
|
+
case 3:
|
|
176
|
+
err_3 = _a.sent();
|
|
177
|
+
revertToPreviousState();
|
|
178
|
+
handleError(err_3, "Failed to update comment vote: ");
|
|
179
|
+
return [3 /*break*/, 5];
|
|
180
|
+
case 4:
|
|
181
|
+
setIsUpdating(false);
|
|
182
|
+
return [7 /*endfinally*/];
|
|
183
|
+
case 5: return [2 /*return*/];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}); };
|
|
187
|
+
var handleRemoveDownvote = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
188
|
+
var updatedComment, err_4;
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
switch (_a.label) {
|
|
191
|
+
case 0:
|
|
192
|
+
if (!user)
|
|
193
|
+
throw new Error("No authenticated user");
|
|
194
|
+
if (isUpdating)
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
// Optimistic update: remove the user's downvote
|
|
197
|
+
updateCommentState(__assign(__assign({}, comment), { downvotes: comment.downvotes.filter(function (id) { return id !== user.id; }) }));
|
|
198
|
+
setIsUpdating(true);
|
|
199
|
+
_a.label = 1;
|
|
200
|
+
case 1:
|
|
201
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
202
|
+
return [4 /*yield*/, removeDownvoteRequest({
|
|
203
|
+
commentId: comment.id,
|
|
204
|
+
})];
|
|
205
|
+
case 2:
|
|
206
|
+
updatedComment = _a.sent();
|
|
207
|
+
setComment(updatedComment);
|
|
208
|
+
return [3 /*break*/, 5];
|
|
209
|
+
case 3:
|
|
210
|
+
err_4 = _a.sent();
|
|
211
|
+
revertToPreviousState();
|
|
212
|
+
handleError(err_4, "Failed to remove downvote from comment: ");
|
|
213
|
+
return [3 /*break*/, 5];
|
|
214
|
+
case 4:
|
|
215
|
+
setIsUpdating(false);
|
|
216
|
+
return [7 /*endfinally*/];
|
|
217
|
+
case 5: return [2 /*return*/];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}); };
|
|
144
221
|
return {
|
|
145
222
|
upvoteComment: handleUpvote,
|
|
146
223
|
removeCommentUpvote: handleRemoveUpvote,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCommentVotes.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useCommentVotes.tsx"],"names":[],"mappings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KAAK,CAAC,uBAAuB,CAAC,CAAC;oBACpD,IAAI,UAAU;wBAAE,sBAAO;oBAEvB,gDAAgD;oBAChD,kBAAkB,uBACb,OAAO,KACV,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,KAAK,IAAI,CAAC,EAAE,EAAd,CAAc,CAAC,IAC3D,CAAC;oBAEH,aAAa,CAAC,IAAI,CAAC,CAAC;;;;oBAEK,qBAAM,qBAAqB,CAAC;4BACjD,SAAS,EAAE,OAAO,CAAC,EAAE;yBACtB,CAAC,EAAA;;oBAFI,cAAc,GAAG,SAErB;oBACF,UAAU,CAAC,cAAc,CAAC,CAAC;;;;oBAE3B,qBAAqB,EAAE,CAAC;oBACxB,WAAW,CAAC,KAAG,EAAE,0CAA0C,CAAC,CAAC;;;oBAE7D,aAAa,CAAC,KAAK,CAAC,CAAC;;;;;SAExB,CAAC;IAEF,OAAO;QACL,aAAa,EAAE,YAAY;QAC3B,mBAAmB,EAAE,kBAAkB;QACvC,eAAe,EAAE,cAAc;QAC/B,qBAAqB,EAAE,oBAAoB;KAC5C,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import { useCallback } from "react";
|
|
38
|
+
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
39
|
+
import useProject from "../projects/useProject";
|
|
40
|
+
function useDownvoteComment() {
|
|
41
|
+
var _this = this;
|
|
42
|
+
var axios = useAxiosPrivate();
|
|
43
|
+
var projectId = useProject().projectId;
|
|
44
|
+
var basePath = projectId ? "/".concat(projectId, "/comments") : null;
|
|
45
|
+
var downvoteComment = useCallback(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
46
|
+
var path, response;
|
|
47
|
+
var commentId = _b.commentId;
|
|
48
|
+
return __generator(this, function (_c) {
|
|
49
|
+
switch (_c.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (!commentId) {
|
|
52
|
+
throw new Error("No comment ID passed");
|
|
53
|
+
}
|
|
54
|
+
if (!basePath) {
|
|
55
|
+
throw new Error("No project specified");
|
|
56
|
+
}
|
|
57
|
+
path = [basePath, commentId, "downvote"].join("/");
|
|
58
|
+
return [4 /*yield*/, axios.patch(path)];
|
|
59
|
+
case 1:
|
|
60
|
+
response = _c.sent();
|
|
61
|
+
return [2 /*return*/, response.data];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); }, [axios, basePath]);
|
|
65
|
+
return downvoteComment;
|
|
66
|
+
}
|
|
67
|
+
export default useDownvoteComment;
|
|
68
|
+
//# sourceMappingURL=useDownvoteComment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDownvoteComment.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useDownvoteComment.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,SAAS,kBAAkB;IAA3B,iBAqBC;IApBC,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IACxB,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IACnC,IAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,WAAI,SAAS,cAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAE7D,IAAM,eAAe,GAAG,WAAW,CACjC,gEAAO,EAAoC;;YAAlC,SAAS,eAAA;;;;oBAChB,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACD,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACK,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACxC,qBAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;oBACxC,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;SACtB,EACD,CAAC,KAAK,EAAE,QAAQ,CAAC,CAClB,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import { useCallback } from "react";
|
|
38
|
+
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
39
|
+
import useProject from "../projects/useProject";
|
|
40
|
+
function useRemoveCommentDownvote() {
|
|
41
|
+
var _this = this;
|
|
42
|
+
var axios = useAxiosPrivate();
|
|
43
|
+
var projectId = useProject().projectId;
|
|
44
|
+
var basePath = projectId ? "/".concat(projectId, "/comments") : null;
|
|
45
|
+
var removeCommentDownvote = useCallback(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
46
|
+
var path, response;
|
|
47
|
+
var commentId = _b.commentId;
|
|
48
|
+
return __generator(this, function (_c) {
|
|
49
|
+
switch (_c.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (!commentId) {
|
|
52
|
+
throw new Error("No comment ID passed");
|
|
53
|
+
}
|
|
54
|
+
if (!basePath) {
|
|
55
|
+
throw new Error("No project specified");
|
|
56
|
+
}
|
|
57
|
+
path = [basePath, commentId, "remove-downvote"].join("/");
|
|
58
|
+
return [4 /*yield*/, axios.patch(path)];
|
|
59
|
+
case 1:
|
|
60
|
+
response = _c.sent();
|
|
61
|
+
return [2 /*return*/, response.data];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); }, [axios, basePath]);
|
|
65
|
+
return removeCommentDownvote;
|
|
66
|
+
}
|
|
67
|
+
export default useRemoveCommentDownvote;
|
|
68
|
+
//# sourceMappingURL=useRemoveCommentDownvote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRemoveCommentDownvote.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useRemoveCommentDownvote.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,SAAS,wBAAwB;IAAjC,iBAqBC;IApBC,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IACxB,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IACnC,IAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,WAAI,SAAS,cAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAE7D,IAAM,qBAAqB,GAAG,WAAW,CACvC,gEAAO,EAAoC;;YAAlC,SAAS,eAAA;;;;oBAChB,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACD,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACK,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,iBAAiB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAC/C,qBAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;oBACxC,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;SACtB,EACD,CAAC,KAAK,EAAE,QAAQ,CAAC,CAClB,CAAC;IAEF,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import { useCallback } from "react";
|
|
38
|
+
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
39
|
+
import useProject from "../projects/useProject";
|
|
40
|
+
function useRemoveCommentUpvote() {
|
|
41
|
+
var _this = this;
|
|
42
|
+
var axios = useAxiosPrivate();
|
|
43
|
+
var projectId = useProject().projectId;
|
|
44
|
+
var basePath = projectId ? "/".concat(projectId, "/comments") : null;
|
|
45
|
+
var removeCommentUpvote = useCallback(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
46
|
+
var path, response;
|
|
47
|
+
var commentId = _b.commentId;
|
|
48
|
+
return __generator(this, function (_c) {
|
|
49
|
+
switch (_c.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (!commentId) {
|
|
52
|
+
throw new Error("No comment ID passed");
|
|
53
|
+
}
|
|
54
|
+
if (!basePath) {
|
|
55
|
+
throw new Error("No project specified");
|
|
56
|
+
}
|
|
57
|
+
path = [basePath, commentId, "remove-upvote"].join("/");
|
|
58
|
+
return [4 /*yield*/, axios.patch(path)];
|
|
59
|
+
case 1:
|
|
60
|
+
response = _c.sent();
|
|
61
|
+
return [2 /*return*/, response.data];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); }, [axios, basePath]);
|
|
65
|
+
return removeCommentUpvote;
|
|
66
|
+
}
|
|
67
|
+
export default useRemoveCommentUpvote;
|
|
68
|
+
//# sourceMappingURL=useRemoveCommentUpvote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRemoveCommentUpvote.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useRemoveCommentUpvote.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,SAAS,sBAAsB;IAA/B,iBAqBC;IApBC,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IACxB,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IACnC,IAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,WAAI,SAAS,cAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAE7D,IAAM,mBAAmB,GAAG,WAAW,CACrC,gEAAO,EAAoC;;YAAlC,SAAS,eAAA;;;;oBAChB,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACD,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACK,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAC7C,qBAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;oBACxC,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;SACtB,EACD,CAAC,KAAK,EAAE,QAAQ,CAAC,CAClB,CAAC;IAEF,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import { useCallback } from "react";
|
|
38
|
+
import useAxiosPrivate from "../../config/useAxiosPrivate";
|
|
39
|
+
import useProject from "../projects/useProject";
|
|
40
|
+
function useUpvoteComment() {
|
|
41
|
+
var _this = this;
|
|
42
|
+
var axios = useAxiosPrivate();
|
|
43
|
+
var projectId = useProject().projectId;
|
|
44
|
+
var basePath = projectId ? "/".concat(projectId, "/comments") : null;
|
|
45
|
+
var upvoteComment = useCallback(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
46
|
+
var path, response;
|
|
47
|
+
var commentId = _b.commentId;
|
|
48
|
+
return __generator(this, function (_c) {
|
|
49
|
+
switch (_c.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (!commentId) {
|
|
52
|
+
throw new Error("No comment ID passed");
|
|
53
|
+
}
|
|
54
|
+
if (!basePath) {
|
|
55
|
+
throw new Error("No project specified");
|
|
56
|
+
}
|
|
57
|
+
path = [basePath, commentId, "upvote"].join("/");
|
|
58
|
+
return [4 /*yield*/, axios.patch(path)];
|
|
59
|
+
case 1:
|
|
60
|
+
response = _c.sent();
|
|
61
|
+
return [2 /*return*/, response.data];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}); }, [axios, basePath]);
|
|
65
|
+
return upvoteComment;
|
|
66
|
+
}
|
|
67
|
+
export default useUpvoteComment;
|
|
68
|
+
//# sourceMappingURL=useUpvoteComment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpvoteComment.js","sourceRoot":"","sources":["../../../../src/hooks/comments/useUpvoteComment.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,SAAS,gBAAgB;IAAzB,iBAqBC;IApBC,IAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IACxB,IAAA,SAAS,GAAK,UAAU,EAAE,UAAjB,CAAkB;IACnC,IAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,WAAI,SAAS,cAAW,CAAC,CAAC,CAAC,IAAI,CAAC;IAE7D,IAAM,aAAa,GAAG,WAAW,CAC/B,gEAAO,EAAoC;;YAAlC,SAAS,eAAA;;;;oBAChB,IAAI,CAAC,SAAS,EAAE,CAAC;wBACf,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACD,IAAI,CAAC,QAAQ,EAAE,CAAC;wBACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;oBAC1C,CAAC;oBACK,IAAI,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACtC,qBAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA;;oBAAlC,QAAQ,GAAG,SAAuB;oBACxC,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;SACtB,EACD,CAAC,KAAK,EAAE,QAAQ,CAAC,CAClB,CAAC;IAEF,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|