@logora/debate 0.4.109 → 0.4.111
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/assets/components/auth/subscription_modal/SubscriptionModal.module-xQS4aWtJ.css +1 -0
- package/dist/components/auth/auth_modal/AuthModal.js +38 -29
- package/dist/components/auth/sso_form/SSOForm.js +36 -33
- package/dist/components/auth/subscription_modal/SubscriptionModal.js +26 -0
- package/dist/components/auth/subscription_modal/SubscriptionModal.module.scss.js +9 -0
- package/dist/components/auth/subscription_modal/index.js +4 -0
- package/dist/components/debate/debate_box/DebateBox.js +51 -51
- package/dist/components/hooks/use_auth_required/useAuthRequired.js +22 -10
- package/dist/components/input/argument_input/ArgumentInput.js +145 -145
- package/dist/components/vote/use_vote/useVote.js +20 -20
- package/dist/index.js +232 -228
- package/package.json +1 -1
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { storePendingReply as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { useLocation as
|
|
1
|
+
import { jsxs as w, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { storePendingReply as Xe } from "../../util/pending_reply/pendingReply.js";
|
|
3
|
+
import { useRef as ve, useState as d, useEffect as M, Suspense as Ze, lazy as et } from "react";
|
|
4
|
+
import { useIntl as tt, FormattedMessage as Se } from "react-intl";
|
|
5
|
+
import { useLocation as nt } from "react-router";
|
|
6
6
|
import I from "classnames";
|
|
7
7
|
import n from "./ArgumentInput.module.scss.js";
|
|
8
|
-
import { useDataProvider as
|
|
9
|
-
import { useList as
|
|
10
|
-
import { useConfig as
|
|
11
|
-
import { useInput as
|
|
12
|
-
import { useAuth as
|
|
13
|
-
import { useFormValidation as
|
|
14
|
-
import { useResponsive as
|
|
15
|
-
import { useScrollToEditor as
|
|
16
|
-
import { useSessionStorageState as
|
|
17
|
-
import { useAuthRequired as
|
|
18
|
-
import { useModal as
|
|
19
|
-
import { useToast as
|
|
20
|
-
import { TogglePosition as
|
|
21
|
-
import { Avatar as
|
|
22
|
-
import { AuthorBox as
|
|
23
|
-
import { TextEditor as
|
|
24
|
-
import { Icon as
|
|
25
|
-
const
|
|
8
|
+
import { useDataProvider as at } from "../../data/data_provider/useDataProvider.js";
|
|
9
|
+
import { useList as st } from "../../list/list_provider/useList.js";
|
|
10
|
+
import { useConfig as it } from "../../data/config_provider/useConfig.js";
|
|
11
|
+
import { useInput as ot } from "../input_provider/useInput.js";
|
|
12
|
+
import { useAuth as rt } from "../../auth/use_auth/useAuth.js";
|
|
13
|
+
import { useFormValidation as ut } from "../../forms/use_form_validation/useFormValidation.js";
|
|
14
|
+
import { useResponsive as dt } from "../../hooks/use_responsive/useResponsive.js";
|
|
15
|
+
import { useScrollToEditor as lt } from "../use_scroll_to_editor/useScrollToEditor.js";
|
|
16
|
+
import { useSessionStorageState as ct } from "../../hooks/use_session_storage_state/useSessionStorageState.js";
|
|
17
|
+
import { useSubscriptionRequired as mt, useAuthRequired as ft } from "../../hooks/use_auth_required/useAuthRequired.js";
|
|
18
|
+
import { useModal as gt } from "../../dialog/modal/useModal.js";
|
|
19
|
+
import { useToast as ht } from "../../dialog/toast_provider/useToast.js";
|
|
20
|
+
import { TogglePosition as pt } from "../toggle_position/TogglePosition.js";
|
|
21
|
+
import { Avatar as _t } from "../../user/avatar/Avatar.js";
|
|
22
|
+
import { AuthorBox as Mt } from "../../user/author_box/AuthorBox.js";
|
|
23
|
+
import { TextEditor as bt } from "../text_editor/TextEditor.js";
|
|
24
|
+
import { Icon as vt } from "../../icons/icon/Icon.js";
|
|
25
|
+
const St = et(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Ae = 2e4, zt = ({
|
|
26
26
|
argumentListId: x,
|
|
27
|
-
avatarSize:
|
|
28
|
-
disabled:
|
|
27
|
+
avatarSize: we = 48,
|
|
28
|
+
disabled: G = !1,
|
|
29
29
|
positions: a = [],
|
|
30
30
|
disabledPositions: N = [],
|
|
31
31
|
groupId: f,
|
|
32
|
-
groupName:
|
|
33
|
-
groupType:
|
|
34
|
-
hideSourceAction:
|
|
32
|
+
groupName: Ce,
|
|
33
|
+
groupType: H,
|
|
34
|
+
hideSourceAction: ye = !1,
|
|
35
35
|
isReply: o = !1,
|
|
36
|
-
onSubmit:
|
|
37
|
-
onUpdate:
|
|
36
|
+
onSubmit: Q,
|
|
37
|
+
onUpdate: X,
|
|
38
38
|
parentId: m,
|
|
39
|
-
ancestorIds:
|
|
40
|
-
placeholder:
|
|
41
|
-
positionId:
|
|
42
|
-
focusOnInit:
|
|
39
|
+
ancestorIds: Ie = [],
|
|
40
|
+
placeholder: xe,
|
|
41
|
+
positionId: C,
|
|
42
|
+
focusOnInit: Ne = !1,
|
|
43
43
|
activeOnInit: Y = !1,
|
|
44
|
-
userGuideUrl:
|
|
45
|
-
hideUserGuideLink:
|
|
46
|
-
hideCharCount:
|
|
47
|
-
disableAutoActivate:
|
|
48
|
-
autoFocus:
|
|
44
|
+
userGuideUrl: Z,
|
|
45
|
+
hideUserGuideLink: Te = !1,
|
|
46
|
+
hideCharCount: Le = !1,
|
|
47
|
+
disableAutoActivate: Pe = !1,
|
|
48
|
+
autoFocus: ee = !1
|
|
49
49
|
}) => {
|
|
50
|
-
const r =
|
|
51
|
-
focus:
|
|
52
|
-
setFocus:
|
|
50
|
+
const r = tt(), te = at(), T = st(), b = it(), {
|
|
51
|
+
focus: ne,
|
|
52
|
+
setFocus: ae,
|
|
53
53
|
inputContent: $,
|
|
54
|
-
setInputContent:
|
|
55
|
-
setInputRichContent:
|
|
56
|
-
} =
|
|
54
|
+
setInputContent: se,
|
|
55
|
+
setInputRichContent: Fe
|
|
56
|
+
} = ot(), { isLoggedIn: v, currentUser: l } = rt(), { errors: U, validate: R } = ut(), { isMobile: g } = dt(), Ee = nt(), ie = ve(null), L = lt(ie), [V, D] = d([]), [W, k] = d(""), [oe, O] = d(null), [c, S] = d(null), [re, ue] = d(null), [de, le] = d(!1), [y, ce] = d(!1), [A, me] = d({}), [Be, j] = d(!1), [qe, Ye] = d(0), P = ve(!1), [$e, fe] = d(!1), [h, Ue] = ct(
|
|
57
57
|
"userSide",
|
|
58
58
|
{}
|
|
59
|
-
), [p,
|
|
60
|
-
!
|
|
61
|
-
),
|
|
62
|
-
typeof window < "u" ? window.location.search :
|
|
59
|
+
), F = mt(), [p, Re] = d(
|
|
60
|
+
!v && b?.actions?.disableInputForVisitor || F
|
|
61
|
+
), z = ft(), { showModal: Ve } = gt(), { toast: E } = ht() || {}, ge = new URLSearchParams(
|
|
62
|
+
typeof window < "u" ? window.location.search : Ee.search
|
|
63
63
|
);
|
|
64
64
|
M(() => {
|
|
65
|
-
|
|
66
|
-
!
|
|
65
|
+
Re(
|
|
66
|
+
!v && b?.actions?.disableInputForVisitor || F
|
|
67
67
|
);
|
|
68
|
-
}, [
|
|
69
|
-
const
|
|
68
|
+
}, [v, b, F]);
|
|
69
|
+
const J = l?.role === "editor" || l?.role === "moderator", he = l?.moderation_status === "banned";
|
|
70
70
|
M(() => {
|
|
71
71
|
let e = null;
|
|
72
|
-
typeof window < "u" && (e =
|
|
73
|
-
}, [
|
|
74
|
-
|
|
75
|
-
}, [
|
|
76
|
-
Y && (
|
|
72
|
+
typeof window < "u" && (e = ge.get("positionId")), C && C != a[2]?.id && a?.find((t) => t.id === C) ? S(C) : e && e != a[2]?.id ? S(e) : h && h.groupId == f && h.positionId != a[2]?.id && S(h.positionId);
|
|
73
|
+
}, [C]), M(() => {
|
|
74
|
+
ee && j(!0);
|
|
75
|
+
}, [ee]), M(() => {
|
|
76
|
+
Y && (K(), j(!0), L());
|
|
77
77
|
}, [Y]), M(() => {
|
|
78
78
|
if (typeof window < "u") {
|
|
79
|
-
const e =
|
|
80
|
-
(e === !0 || e === "true") && (
|
|
79
|
+
const e = Ne || ge.get("initArgument");
|
|
80
|
+
(e === !0 || e === "true") && (j(!0), L(), Ge());
|
|
81
81
|
}
|
|
82
82
|
}, []), M(() => {
|
|
83
|
-
|
|
84
|
-
}, [
|
|
85
|
-
$?.id && !o && (De($),
|
|
83
|
+
ne && !o && (L(), ae(!1));
|
|
84
|
+
}, [ne]), M(() => {
|
|
85
|
+
$?.id && !o && (De($), ae(!0));
|
|
86
86
|
}, [$]);
|
|
87
87
|
const De = (e) => {
|
|
88
|
-
|
|
89
|
-
},
|
|
90
|
-
k(""), O(null),
|
|
88
|
+
me(e), ce(!0), D(e.sources), k(e.content), O(e.rich_content), ue(e.id), L(), S(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Fe(e.rich_content) : se(e.content);
|
|
89
|
+
}, pe = () => {
|
|
90
|
+
k(""), O(null), me({}), ue(null), D([]), Ye((e) => e + 1), se(null);
|
|
91
91
|
}, We = {
|
|
92
92
|
create: {
|
|
93
93
|
id: "alert.argument_create_error",
|
|
@@ -101,23 +101,23 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
101
101
|
id: "alert.argument_rate_limited",
|
|
102
102
|
defaultMessage: "Your contribution could not be sent. Please try again in a few moments."
|
|
103
103
|
}
|
|
104
|
-
},
|
|
104
|
+
}, B = (e, t) => {
|
|
105
105
|
t && console.error("[ArgumentInput] submission failed", t);
|
|
106
106
|
const { id: u, defaultMessage: i } = We[t?.response?.status === 429 ? "rateLimited" : e];
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
P.current = !0,
|
|
107
|
+
E?.(r.formatMessage({ id: u, defaultMessage: i }), { type: "error" });
|
|
108
|
+
}, _e = async (e) => {
|
|
109
|
+
P.current = !0, fe(!0);
|
|
110
110
|
try {
|
|
111
111
|
return await e();
|
|
112
112
|
} finally {
|
|
113
|
-
P.current = !1,
|
|
113
|
+
P.current = !1, fe(!1);
|
|
114
114
|
}
|
|
115
115
|
}, ke = (e) => {
|
|
116
|
-
|
|
116
|
+
S(e), be(e);
|
|
117
117
|
}, Oe = () => {
|
|
118
118
|
Ve(
|
|
119
|
-
/* @__PURE__ */ s(
|
|
120
|
-
|
|
119
|
+
/* @__PURE__ */ s(Ze, { fallback: null, children: /* @__PURE__ */ s(
|
|
120
|
+
St,
|
|
121
121
|
{
|
|
122
122
|
modalTitle: r.formatMessage({
|
|
123
123
|
id: "modal.side_modal.modal_title",
|
|
@@ -125,47 +125,47 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
125
125
|
}),
|
|
126
126
|
onChooseSide: ke,
|
|
127
127
|
positions: a,
|
|
128
|
-
title:
|
|
128
|
+
title: Ce,
|
|
129
129
|
disabledPositions: !o && N,
|
|
130
130
|
isNeutral: h && h.groupId == f && h.positionId === a[2]?.id
|
|
131
131
|
}
|
|
132
132
|
) })
|
|
133
133
|
);
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
p ?
|
|
138
|
-
},
|
|
134
|
+
}, je = () => {
|
|
135
|
+
v && !F ? re ? Ke() : !a || a?.length === 0 || !N?.find((e) => e?.id === c) && c || J && o ? be(o && J && a[0]?.id) : Oe() : (m && !v && Xe({ groupId: f, parentId: m, ancestorIds: Ie }), z({ loginAction: "argument" }));
|
|
136
|
+
}, ze = (e, t) => {
|
|
137
|
+
p ? z({ loginAction: "argument" }) : (k(e), O(t), R({ content: e }, [{ content: ["url", null] }]));
|
|
138
|
+
}, Je = (e) => {
|
|
139
139
|
D(e);
|
|
140
|
-
},
|
|
140
|
+
}, Me = [
|
|
141
141
|
{ content: ["length", 3] },
|
|
142
142
|
{ content: ["required", null] },
|
|
143
143
|
{ content: ["url", null] },
|
|
144
144
|
...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
|
|
145
|
-
],
|
|
145
|
+
], be = (e) => {
|
|
146
146
|
if (P.current)
|
|
147
147
|
return;
|
|
148
148
|
const t = e || c, u = {
|
|
149
149
|
content: W,
|
|
150
|
-
rich_content:
|
|
150
|
+
rich_content: oe,
|
|
151
151
|
group_id: f,
|
|
152
|
-
...
|
|
152
|
+
...H && { group_type: H },
|
|
153
153
|
...t && { position_id: t },
|
|
154
154
|
is_reply: !!m,
|
|
155
155
|
message_id: m || null,
|
|
156
156
|
source_ids: V?.map((i) => i.id)
|
|
157
157
|
};
|
|
158
|
-
|
|
158
|
+
R(u, Me) && (t && a && a.map((i) => i.id).includes(t) && Ue({
|
|
159
159
|
groupId: f,
|
|
160
160
|
positionId: t
|
|
161
|
-
}),
|
|
162
|
-
() =>
|
|
161
|
+
}), _e(
|
|
162
|
+
() => te.create("messages", u, {}, !0, {
|
|
163
163
|
timeout: Ae
|
|
164
164
|
})
|
|
165
165
|
).then((i) => {
|
|
166
166
|
if (i?.data?.success) {
|
|
167
167
|
if (m)
|
|
168
|
-
|
|
168
|
+
Q(i.data.data.resource), E(
|
|
169
169
|
r.formatMessage({
|
|
170
170
|
id: "alert.argument_create",
|
|
171
171
|
defaultMessage: "Your contribution has been sent !"
|
|
@@ -180,11 +180,11 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
180
180
|
);
|
|
181
181
|
else {
|
|
182
182
|
const _ = i.data.data.resource;
|
|
183
|
-
let
|
|
184
|
-
t && !g && (
|
|
183
|
+
let q = x;
|
|
184
|
+
t && !g && (q = `argumentList${_.position.id}`), Q?.(
|
|
185
185
|
W,
|
|
186
|
-
a.find((
|
|
187
|
-
), T.add(
|
|
186
|
+
a.find((Qe) => Qe.id === t) || null
|
|
187
|
+
), T.add(q, [_]), E(
|
|
188
188
|
r.formatMessage({
|
|
189
189
|
id: "alert.argument_create",
|
|
190
190
|
defaultMessage: "Your contribution has been sent !"
|
|
@@ -206,21 +206,21 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
206
206
|
content: i.data.data?.resource
|
|
207
207
|
}
|
|
208
208
|
})
|
|
209
|
-
),
|
|
209
|
+
), pe();
|
|
210
210
|
} else
|
|
211
|
-
|
|
212
|
-
}, (i) =>
|
|
213
|
-
},
|
|
211
|
+
B("create");
|
|
212
|
+
}, (i) => B("create", i)));
|
|
213
|
+
}, Ke = () => {
|
|
214
214
|
if (P.current)
|
|
215
215
|
return;
|
|
216
216
|
const e = {
|
|
217
217
|
content: W,
|
|
218
|
-
rich_content:
|
|
218
|
+
rich_content: oe,
|
|
219
219
|
source_ids: V?.map((t) => t.id),
|
|
220
220
|
...c && { position_id: c }
|
|
221
221
|
};
|
|
222
|
-
|
|
223
|
-
() =>
|
|
222
|
+
R(e, Me) && _e(
|
|
223
|
+
() => te.update("messages", re, e, {}, !0, {
|
|
224
224
|
timeout: Ae
|
|
225
225
|
})
|
|
226
226
|
).then(
|
|
@@ -233,29 +233,29 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
233
233
|
_ && (i = `argument_${_}_reply_list`);
|
|
234
234
|
} else c && !g && (i = `argumentList${u.position?.id}`);
|
|
235
235
|
if (!A?.is_reply && A?.position?.id != u.position?.id && !g) {
|
|
236
|
-
const _ = `argumentList${A.position.id}`,
|
|
237
|
-
T.remove(_, [u]), T.add(
|
|
236
|
+
const _ = `argumentList${A.position.id}`, q = `argumentList${u.position.id}`;
|
|
237
|
+
T.remove(_, [u]), T.add(q, [u]);
|
|
238
238
|
} else
|
|
239
239
|
T.update(i, [u]);
|
|
240
|
-
|
|
240
|
+
X && X(u), E(r.formatMessage({ id: "alert.argument_modify" }), {
|
|
241
241
|
type: "success"
|
|
242
|
-
}),
|
|
242
|
+
}), pe();
|
|
243
243
|
} else
|
|
244
|
-
|
|
244
|
+
B("update");
|
|
245
245
|
},
|
|
246
|
-
(t) =>
|
|
246
|
+
(t) => B("update", t)
|
|
247
247
|
);
|
|
248
|
-
},
|
|
249
|
-
if (!
|
|
250
|
-
|
|
248
|
+
}, Ge = () => {
|
|
249
|
+
if (!de) {
|
|
250
|
+
le(!0);
|
|
251
251
|
const e = setTimeout(() => {
|
|
252
|
-
|
|
252
|
+
le(!1);
|
|
253
253
|
}, 2e3);
|
|
254
254
|
return () => clearTimeout(e);
|
|
255
255
|
}
|
|
256
|
-
},
|
|
257
|
-
p ?
|
|
258
|
-
},
|
|
256
|
+
}, K = () => {
|
|
257
|
+
p ? z({ loginAction: "argument" }) : ce(!0);
|
|
258
|
+
}, He = () => {
|
|
259
259
|
const e = N.find(
|
|
260
260
|
(t) => t.id === c
|
|
261
261
|
);
|
|
@@ -268,8 +268,8 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
268
268
|
{ position: e.name }
|
|
269
269
|
);
|
|
270
270
|
};
|
|
271
|
-
return /* @__PURE__ */
|
|
272
|
-
|
|
271
|
+
return /* @__PURE__ */ w("div", { className: n.inputContainer, children: [
|
|
272
|
+
G && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: he ? r.formatMessage({
|
|
273
273
|
id: "input.argument_input.user_banned",
|
|
274
274
|
defaultMessage: "You are banned from the debate space."
|
|
275
275
|
}) : r.formatMessage({
|
|
@@ -280,26 +280,26 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
280
280
|
"div",
|
|
281
281
|
{
|
|
282
282
|
className: I(n.argumentInput, {
|
|
283
|
-
[n.flash]:
|
|
283
|
+
[n.flash]: de,
|
|
284
284
|
[n.replyInputContainer]: o
|
|
285
285
|
}),
|
|
286
|
-
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref:
|
|
287
|
-
a.length > 0 &&
|
|
286
|
+
children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ie, children: /* @__PURE__ */ w("div", { className: n.argumentInputBox, children: [
|
|
287
|
+
a.length > 0 && v && (!o || !J) && /* @__PURE__ */ w("div", { className: n.userPosition, children: [
|
|
288
288
|
/* @__PURE__ */ s("div", { children: r.formatMessage({
|
|
289
289
|
id: "input.position",
|
|
290
290
|
defaultMessage: "Your position"
|
|
291
291
|
}) }),
|
|
292
292
|
/* @__PURE__ */ s(
|
|
293
|
-
|
|
293
|
+
pt,
|
|
294
294
|
{
|
|
295
295
|
activeLabel: c === a[0].id ? 0 : c === a[1].id ? 1 : null,
|
|
296
296
|
firstLabel: a[0],
|
|
297
297
|
secondLabel: a[1],
|
|
298
|
-
onChange: (e) =>
|
|
298
|
+
onChange: (e) => S(a[e].id)
|
|
299
299
|
}
|
|
300
300
|
)
|
|
301
301
|
] }),
|
|
302
|
-
/* @__PURE__ */
|
|
302
|
+
/* @__PURE__ */ w(
|
|
303
303
|
"div",
|
|
304
304
|
{
|
|
305
305
|
className: I(n.argumentTextInputBox, {
|
|
@@ -315,14 +315,14 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
315
315
|
[n.argumentAuthorContainerActivated]: !g && y || o
|
|
316
316
|
}),
|
|
317
317
|
children: !g && y || o ? /* @__PURE__ */ s(
|
|
318
|
-
|
|
318
|
+
_t,
|
|
319
319
|
{
|
|
320
320
|
avatarUrl: l.image_url,
|
|
321
321
|
userName: l.full_name,
|
|
322
|
-
size:
|
|
322
|
+
size: we
|
|
323
323
|
}
|
|
324
324
|
) : /* @__PURE__ */ s(
|
|
325
|
-
|
|
325
|
+
Mt,
|
|
326
326
|
{
|
|
327
327
|
fullName: l?.full_name || r.formatMessage({ id: "default_author.full_name" }),
|
|
328
328
|
avatarUrl: l?.image_url,
|
|
@@ -332,54 +332,54 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
332
332
|
)
|
|
333
333
|
}
|
|
334
334
|
),
|
|
335
|
-
/* @__PURE__ */
|
|
335
|
+
/* @__PURE__ */ w(
|
|
336
336
|
"div",
|
|
337
337
|
{
|
|
338
|
-
onClick:
|
|
338
|
+
onClick: K,
|
|
339
339
|
"data-testid": "argument-input",
|
|
340
340
|
className: I(n.textEditorBox, {
|
|
341
341
|
[n.replyTextEditorBox]: o
|
|
342
342
|
}),
|
|
343
343
|
children: [
|
|
344
344
|
/* @__PURE__ */ s(
|
|
345
|
-
|
|
345
|
+
bt,
|
|
346
346
|
{
|
|
347
347
|
handleChange: (e, t) => {
|
|
348
|
-
|
|
348
|
+
ze(e, t);
|
|
349
349
|
},
|
|
350
350
|
handleSourcesChange: (e) => {
|
|
351
|
-
|
|
351
|
+
Je(e);
|
|
352
352
|
},
|
|
353
|
-
placeholder:
|
|
353
|
+
placeholder: xe,
|
|
354
354
|
"aria-label": r.formatMessage({
|
|
355
355
|
id: "input.argument_input.aria_label",
|
|
356
356
|
defaultMessage: "Message input field"
|
|
357
357
|
}),
|
|
358
|
-
onSubmit:
|
|
358
|
+
onSubmit: je,
|
|
359
359
|
sources: V,
|
|
360
|
-
hideSourceAction:
|
|
360
|
+
hideSourceAction: ye || p,
|
|
361
361
|
uid: m ? `Reply${f}_${m}` : `Argument${f}`,
|
|
362
|
-
onActivation:
|
|
362
|
+
onActivation: K,
|
|
363
363
|
showStylesControls: y,
|
|
364
|
-
disabled:
|
|
364
|
+
disabled: G || p || he,
|
|
365
365
|
maxLength: p ? !1 : b?.actions?.argumentMaxLength,
|
|
366
366
|
disableRichText: b?.actions?.disableRichText || p,
|
|
367
367
|
shortBar: o,
|
|
368
368
|
isReply: o,
|
|
369
|
-
resetSignal:
|
|
369
|
+
resetSignal: qe,
|
|
370
370
|
hideSubmit: p,
|
|
371
371
|
allowedDomains: b?.allowed_sources,
|
|
372
372
|
active: Y,
|
|
373
|
-
autoFocus:
|
|
374
|
-
hideCharCount:
|
|
375
|
-
disableAutoActivate:
|
|
373
|
+
autoFocus: Be,
|
|
374
|
+
hideCharCount: Le,
|
|
375
|
+
disableAutoActivate: Pe,
|
|
376
376
|
submitting: $e
|
|
377
377
|
}
|
|
378
378
|
),
|
|
379
379
|
U?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: U && Object.values(U).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
|
|
380
380
|
y && N?.find(
|
|
381
381
|
(e) => e.id === c
|
|
382
|
-
) && /* @__PURE__ */
|
|
382
|
+
) && /* @__PURE__ */ w(
|
|
383
383
|
"div",
|
|
384
384
|
{
|
|
385
385
|
className: I(
|
|
@@ -388,7 +388,7 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
388
388
|
),
|
|
389
389
|
children: [
|
|
390
390
|
/* @__PURE__ */ s(
|
|
391
|
-
|
|
391
|
+
vt,
|
|
392
392
|
{
|
|
393
393
|
name: "announcement",
|
|
394
394
|
className: n.warningIcon,
|
|
@@ -396,12 +396,12 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
396
396
|
width: 20
|
|
397
397
|
}
|
|
398
398
|
),
|
|
399
|
-
/* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children:
|
|
399
|
+
/* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: He() })
|
|
400
400
|
]
|
|
401
401
|
}
|
|
402
402
|
),
|
|
403
|
-
y &&
|
|
404
|
-
|
|
403
|
+
y && Z && !Te && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
|
|
404
|
+
Se,
|
|
405
405
|
{
|
|
406
406
|
id: "alert.guide_message",
|
|
407
407
|
defaultMessage: "Contributions must comply with our {userCharter}.",
|
|
@@ -410,11 +410,11 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
410
410
|
"a",
|
|
411
411
|
{
|
|
412
412
|
className: n.guideMessage,
|
|
413
|
-
href:
|
|
413
|
+
href: Z,
|
|
414
414
|
target: "_blank",
|
|
415
415
|
rel: "noreferrer",
|
|
416
416
|
children: /* @__PURE__ */ s(
|
|
417
|
-
|
|
417
|
+
Se,
|
|
418
418
|
{
|
|
419
419
|
id: "alert.user_charter",
|
|
420
420
|
defaultMessage: "user charter"
|
|
@@ -437,5 +437,5 @@ const bt = Ze(() => import("../../modal/side_modal/index.js").then((x) => ({ def
|
|
|
437
437
|
] });
|
|
438
438
|
};
|
|
439
439
|
export {
|
|
440
|
-
|
|
440
|
+
zt as ArgumentInput
|
|
441
441
|
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { useContext as H, useState as n, useEffect as I } from "react";
|
|
2
2
|
import { VoteContext as O } from "../vote_provider/VoteProvider.js";
|
|
3
3
|
import { useAuth as P } from "../../auth/use_auth/useAuth.js";
|
|
4
|
-
import { useDataProvider as
|
|
5
|
-
import { useAuthRequired as
|
|
6
|
-
const
|
|
7
|
-
const { votes:
|
|
4
|
+
import { useDataProvider as z } from "../../data/data_provider/useDataProvider.js";
|
|
5
|
+
import { useAuthRequired as F, useSubscriptionRequired as G } from "../../hooks/use_auth_required/useAuthRequired.js";
|
|
6
|
+
const Y = (S, i, k, x, v = null) => {
|
|
7
|
+
const { votes: d, voteableIds: w, votesLoading: L } = H(O), { isLoggedIn: f } = P(), V = z(), A = Array.isArray(w) && w.includes(i) && L, [T, h] = n(!1), [b, D] = n(!0), [g, m] = n(), [l, _] = n(k), [u, q] = n(x), [R, s] = n(!1), [C, y] = n(!1), j = F(), B = G();
|
|
8
8
|
I(() => {
|
|
9
|
-
if (!
|
|
10
|
-
const e =
|
|
11
|
-
|
|
9
|
+
if (!C && f && Object.keys(d).length > 0 && i in d) {
|
|
10
|
+
const e = d[i];
|
|
11
|
+
y(!0), h(!!e), D(e?.is_upvote), m(e?.id);
|
|
12
12
|
}
|
|
13
|
-
}, [
|
|
13
|
+
}, [d, f]);
|
|
14
14
|
const r = (e) => {
|
|
15
|
-
h(!0),
|
|
15
|
+
h(!0), D(e);
|
|
16
16
|
const t = e ? l + 1 : l, o = e ? u : u + 1;
|
|
17
|
-
v?.(e, !0, t, o), e ? _((a) => a + 1) :
|
|
17
|
+
v?.(e, !0, t, o), e ? _((a) => a + 1) : q((a) => a + 1);
|
|
18
18
|
}, c = (e) => {
|
|
19
19
|
h(!1);
|
|
20
20
|
const t = e ? l - 1 : l, o = e ? u : u - 1;
|
|
21
|
-
v?.(e, !1, t, o), e ? _((a) => a - 1) :
|
|
21
|
+
v?.(e, !1, t, o), e ? _((a) => a - 1) : q((a) => a - 1);
|
|
22
22
|
}, E = (e) => {
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
c(e), s(!0), V.delete("votes",
|
|
23
|
+
if (y(!0), T)
|
|
24
|
+
if (b === e)
|
|
25
|
+
c(e), s(!0), V.delete("votes", g).then(
|
|
26
26
|
(t) => {
|
|
27
27
|
t.data?.success ? m(null) : r(e), s(!1);
|
|
28
28
|
},
|
|
@@ -35,7 +35,7 @@ const W = (x, d, L, S, v = null) => {
|
|
|
35
35
|
const t = {
|
|
36
36
|
is_upvote: e
|
|
37
37
|
};
|
|
38
|
-
s(!0), V.update("votes",
|
|
38
|
+
s(!0), V.update("votes", g, t).then(
|
|
39
39
|
(o) => {
|
|
40
40
|
o.data?.success || (c(e), r(!e)), s(!1);
|
|
41
41
|
},
|
|
@@ -46,8 +46,8 @@ const W = (x, d, L, S, v = null) => {
|
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
const t = {
|
|
49
|
-
voteable_id:
|
|
50
|
-
voteable_type:
|
|
49
|
+
voteable_id: i,
|
|
50
|
+
voteable_type: S,
|
|
51
51
|
is_upvote: e
|
|
52
52
|
};
|
|
53
53
|
r(e), s(!0), V.create("votes", t).then(
|
|
@@ -64,13 +64,13 @@ const W = (x, d, L, S, v = null) => {
|
|
|
64
64
|
totalUpvotes: l,
|
|
65
65
|
totalDownvotes: u,
|
|
66
66
|
activeVote: T,
|
|
67
|
-
voteSide:
|
|
67
|
+
voteSide: b,
|
|
68
68
|
handleVote: (e) => {
|
|
69
|
-
!
|
|
69
|
+
!R && !A && (f && !B ? E(e) : j({ loginAction: "vote" }));
|
|
70
70
|
},
|
|
71
71
|
voteLoading: A
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
export {
|
|
75
|
-
|
|
75
|
+
Y as useVote
|
|
76
76
|
};
|