@logora/debate 0.3.48 → 0.3.49
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as _, jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useIntl as
|
|
2
|
+
import $e from "@rooks/use-sessionstorage-state";
|
|
3
|
+
import { useRef as qe, useState as c, useEffect as M, Suspense as De, lazy as We } from "react";
|
|
4
|
+
import { useIntl as Ye, FormattedMessage as ce } from "react-intl";
|
|
5
5
|
import { useLocation as ke } from "react-router";
|
|
6
6
|
import w from "classnames";
|
|
7
7
|
import n from "./ArgumentInput.module.scss.js";
|
|
@@ -20,7 +20,7 @@ import { Avatar as et } from "../../user/avatar/Avatar.js";
|
|
|
20
20
|
import { AuthorBox as tt } from "../../user/author_box/AuthorBox.js";
|
|
21
21
|
import { TextEditor as nt } from "../text_editor/TextEditor.js";
|
|
22
22
|
import { Icon as at } from "../../icons/icon/Icon.js";
|
|
23
|
-
const it =
|
|
23
|
+
const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ default: I.SideModal }))), Nt = ({
|
|
24
24
|
argumentListId: I,
|
|
25
25
|
avatarSize: me = 48,
|
|
26
26
|
disabled: j = !1,
|
|
@@ -30,9 +30,9 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
30
30
|
groupName: fe,
|
|
31
31
|
groupType: z,
|
|
32
32
|
hideSourceAction: ge = !1,
|
|
33
|
-
isReply:
|
|
33
|
+
isReply: u = !1,
|
|
34
34
|
onSubmit: O,
|
|
35
|
-
parentId:
|
|
35
|
+
parentId: L,
|
|
36
36
|
placeholder: he,
|
|
37
37
|
positionId: b,
|
|
38
38
|
focusOnInit: pe = !1,
|
|
@@ -42,19 +42,19 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
42
42
|
hideCharCount: Me = !1,
|
|
43
43
|
disableAutoActivate: ve = !1
|
|
44
44
|
}) => {
|
|
45
|
-
const
|
|
45
|
+
const o = Ye(), K = Re(), x = je(), h = ze(), {
|
|
46
46
|
focus: G,
|
|
47
47
|
setFocus: N,
|
|
48
48
|
setReset: be,
|
|
49
49
|
inputContent: P,
|
|
50
50
|
setInputContent: Ae,
|
|
51
51
|
setInputRichContent: Ce
|
|
52
|
-
} = Oe(), { isLoggedIn: A, currentUser:
|
|
52
|
+
} = Oe(), { isLoggedIn: A, currentUser: d } = Je(), { errors: B, validate: E } = Ke(), { isMobile: m } = Ge(), we = ke(), H = qe(null), [V, U] = c([]), [$, q] = c(""), [Q, D] = c(null), [l, p] = c(null), [X, Z] = c(null), [ee, te] = c(!1), [C, ne] = c(!1), [ae, ie] = c({}), [f, Ie] = $e(
|
|
53
53
|
"userSide",
|
|
54
54
|
{}
|
|
55
55
|
), [g, Se] = c(
|
|
56
56
|
!A && h?.actions?.disableInputForVisitor
|
|
57
|
-
),
|
|
57
|
+
), W = He(), { showModal: xe } = Qe(), { toast: Y } = Xe() || {}, se = new URLSearchParams(
|
|
58
58
|
typeof window < "u" ? window.location.search : we.search
|
|
59
59
|
);
|
|
60
60
|
M(() => {
|
|
@@ -62,7 +62,7 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
62
62
|
!A && h?.actions?.disableInputForVisitor
|
|
63
63
|
);
|
|
64
64
|
}, [A, h]);
|
|
65
|
-
const k =
|
|
65
|
+
const k = d?.role === "editor" || d?.role === "moderator", oe = d?.moderation_status === "banned";
|
|
66
66
|
M(() => {
|
|
67
67
|
let e = null;
|
|
68
68
|
typeof window < "u" && (e = se.get("positionId")), b && b != a[2]?.id && a?.find((t) => t.id === b) ? p(b) : e && e != a[2]?.id ? p(e) : f && f.groupId == v && f.positionId != a[2]?.id && p(f.positionId);
|
|
@@ -79,34 +79,34 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
79
79
|
P?.id && (Ne(P), N(!0));
|
|
80
80
|
}, [P]);
|
|
81
81
|
const Ne = (e) => {
|
|
82
|
-
ie(e), ne(!0), U(e.sources),
|
|
82
|
+
ie(e), ne(!0), U(e.sources), q(e.content), D(e.rich_content), Z(e.id), re(), p(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ce(e.rich_content) : Ae(e.content);
|
|
83
83
|
}, re = () => {
|
|
84
84
|
H.current.scrollIntoView(!1);
|
|
85
85
|
}, ue = () => {
|
|
86
|
-
|
|
86
|
+
q(""), D(null), ie({}), Z(null), U([]), be(!0);
|
|
87
87
|
}, Te = (e) => {
|
|
88
88
|
p(e), le(e);
|
|
89
|
-
},
|
|
89
|
+
}, ye = () => {
|
|
90
90
|
xe(
|
|
91
|
-
/* @__PURE__ */ i(
|
|
91
|
+
/* @__PURE__ */ i(De, { fallback: null, children: /* @__PURE__ */ i(
|
|
92
92
|
it,
|
|
93
93
|
{
|
|
94
|
-
modalTitle:
|
|
94
|
+
modalTitle: o.formatMessage({
|
|
95
95
|
id: "modal.side_modal.modal_title",
|
|
96
96
|
defaultMessage: "Choose your side"
|
|
97
97
|
}),
|
|
98
98
|
onChooseSide: Te,
|
|
99
99
|
positions: a,
|
|
100
100
|
title: fe,
|
|
101
|
-
disabledPositions: !
|
|
101
|
+
disabledPositions: !u && S,
|
|
102
102
|
isNeutral: f && f.groupId == v && f.positionId === a[2]?.id
|
|
103
103
|
}
|
|
104
104
|
) })
|
|
105
105
|
);
|
|
106
|
-
},
|
|
107
|
-
A ? X ? Be() : !a || a?.length === 0 || !S?.find((e) => e?.id ===
|
|
106
|
+
}, Le = () => {
|
|
107
|
+
A ? X ? Be() : !a || a?.length === 0 || !S?.find((e) => e?.id === l) && l || k && u ? le(u && k && a[0]?.id) : ye() : W({ loginAction: "argument" });
|
|
108
108
|
}, Fe = (e, t) => {
|
|
109
|
-
g ?
|
|
109
|
+
g ? W({ loginAction: "argument" }) : (q(e), D(t), E({ content: e }, [{ content: ["url", null] }]));
|
|
110
110
|
}, Pe = (e) => {
|
|
111
111
|
U(e);
|
|
112
112
|
}, de = [
|
|
@@ -115,61 +115,61 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
115
115
|
{ content: ["url", null] },
|
|
116
116
|
...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
|
|
117
117
|
], le = (e) => {
|
|
118
|
-
const t = e ||
|
|
119
|
-
content:
|
|
118
|
+
const t = e || l, r = {
|
|
119
|
+
content: $,
|
|
120
120
|
rich_content: Q,
|
|
121
121
|
group_id: v,
|
|
122
122
|
...z && { group_type: z },
|
|
123
123
|
...t && { position_id: t },
|
|
124
|
-
is_reply: !!
|
|
125
|
-
message_id:
|
|
126
|
-
source_ids: V?.map((
|
|
124
|
+
is_reply: !!L,
|
|
125
|
+
message_id: L || null,
|
|
126
|
+
source_ids: V?.map((s) => s.id)
|
|
127
127
|
};
|
|
128
|
-
E(
|
|
128
|
+
E(r, de) && (t && a && a.map((s) => s.id).includes(t) && Ie({
|
|
129
129
|
groupId: v,
|
|
130
130
|
positionId: t
|
|
131
|
-
}), ue(), K.create("messages",
|
|
132
|
-
if (
|
|
133
|
-
if (
|
|
134
|
-
O(
|
|
135
|
-
|
|
131
|
+
}), ue(), K.create("messages", r).then((s) => {
|
|
132
|
+
if (s.data.success) {
|
|
133
|
+
if (L)
|
|
134
|
+
O(s.data.data.resource), Y(
|
|
135
|
+
o.formatMessage({
|
|
136
136
|
id: "alert.argument_create",
|
|
137
137
|
defaultMessage: "Your contribution has been sent !"
|
|
138
138
|
}),
|
|
139
139
|
{
|
|
140
140
|
type: "success",
|
|
141
|
-
points:
|
|
141
|
+
points: o.formatMessage({
|
|
142
142
|
id: "alert.reply_gain",
|
|
143
143
|
defaultMessage: " "
|
|
144
144
|
})
|
|
145
145
|
}
|
|
146
146
|
);
|
|
147
147
|
else {
|
|
148
|
-
const T =
|
|
149
|
-
let
|
|
150
|
-
t && !m && (
|
|
151
|
-
|
|
148
|
+
const T = s.data.data.resource;
|
|
149
|
+
let y = I;
|
|
150
|
+
t && !m && (y = `argumentList${T.position.id}`), O?.(
|
|
151
|
+
$,
|
|
152
152
|
a.find((Ue) => Ue.id === t) || null
|
|
153
|
-
), x.add(
|
|
154
|
-
|
|
153
|
+
), x.add(y, [T]), Y(
|
|
154
|
+
o.formatMessage({
|
|
155
155
|
id: "alert.argument_create",
|
|
156
156
|
defaultMessage: "Your contribution has been sent !"
|
|
157
157
|
}),
|
|
158
158
|
{
|
|
159
159
|
type: "success",
|
|
160
|
-
points:
|
|
160
|
+
points: o.formatMessage({
|
|
161
161
|
id: "alert.argument_create_gain",
|
|
162
162
|
defaultMessage: "Up to 10 eloquence points"
|
|
163
163
|
}),
|
|
164
164
|
category: "ARGUMENT",
|
|
165
|
-
contentKey:
|
|
165
|
+
contentKey: d.messages_count === 2 ? "alert.third_argument" : "alert.first_argument"
|
|
166
166
|
}
|
|
167
167
|
);
|
|
168
168
|
}
|
|
169
169
|
typeof window < "u" && window.dispatchEvent(
|
|
170
170
|
new CustomEvent("logora:user_content:created", {
|
|
171
171
|
detail: {
|
|
172
|
-
content:
|
|
172
|
+
content: s.data.data?.resource
|
|
173
173
|
}
|
|
174
174
|
})
|
|
175
175
|
);
|
|
@@ -177,21 +177,21 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
177
177
|
}));
|
|
178
178
|
}, Be = () => {
|
|
179
179
|
const e = {
|
|
180
|
-
content:
|
|
180
|
+
content: $,
|
|
181
181
|
rich_content: Q,
|
|
182
182
|
source_ids: V?.map((t) => t.id),
|
|
183
|
-
...
|
|
183
|
+
...l && { position_id: l }
|
|
184
184
|
};
|
|
185
185
|
E(e, de) && K.update("messages", X, e).then((t) => {
|
|
186
186
|
if (t.data.success) {
|
|
187
|
-
const
|
|
188
|
-
let
|
|
189
|
-
if (
|
|
190
|
-
const T = `argumentList${ae.position.id}`,
|
|
191
|
-
x.remove(T, [
|
|
187
|
+
const r = t.data.data.resource;
|
|
188
|
+
let s = I;
|
|
189
|
+
if (r.is_reply ? s = `argument_${r.message_id}_reply_list` : l && !m && (s = `argumentList${r.position?.id}`), ae?.position?.id != r.position?.id && !m && !r.is_reply) {
|
|
190
|
+
const T = `argumentList${ae.position.id}`, y = `argumentList${r.position.id}`;
|
|
191
|
+
x.remove(T, [r]), x.add(y, [r]);
|
|
192
192
|
} else
|
|
193
|
-
x.update(
|
|
194
|
-
|
|
193
|
+
x.update(s, [r]);
|
|
194
|
+
Y(o.formatMessage({ id: "alert.argument_modify" }), {
|
|
195
195
|
type: "success"
|
|
196
196
|
}), ue();
|
|
197
197
|
}
|
|
@@ -205,13 +205,13 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
205
205
|
return () => clearTimeout(e);
|
|
206
206
|
}
|
|
207
207
|
}, R = () => {
|
|
208
|
-
g ?
|
|
208
|
+
g ? W({ loginAction: "argument" }) : ne(!0);
|
|
209
209
|
}, Ve = () => {
|
|
210
210
|
const e = S.find(
|
|
211
|
-
(t) => t.id ===
|
|
211
|
+
(t) => t.id === l
|
|
212
212
|
);
|
|
213
213
|
if (e)
|
|
214
|
-
return
|
|
214
|
+
return o.formatMessage(
|
|
215
215
|
{
|
|
216
216
|
id: "info.argument_side_limit",
|
|
217
217
|
defaultMessage: "You have reached the argument limit (10) for position {position}."
|
|
@@ -220,10 +220,10 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
220
220
|
);
|
|
221
221
|
};
|
|
222
222
|
return /* @__PURE__ */ _("div", { className: n.inputContainer, children: [
|
|
223
|
-
j && /* @__PURE__ */ i("div", { className: n.disabledInputMask, children: oe ?
|
|
223
|
+
j && /* @__PURE__ */ i("div", { className: n.disabledInputMask, children: oe ? o.formatMessage({
|
|
224
224
|
id: "input.argument_input.user_banned",
|
|
225
225
|
defaultMessage: "You are banned from the debate space."
|
|
226
|
-
}) :
|
|
226
|
+
}) : o.formatMessage({
|
|
227
227
|
id: "info.debate_is_inactive",
|
|
228
228
|
defaultMessage: "Debate is closed"
|
|
229
229
|
}) }),
|
|
@@ -232,18 +232,18 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
232
232
|
{
|
|
233
233
|
className: w(n.argumentInput, {
|
|
234
234
|
[n.flash]: ee,
|
|
235
|
-
[n.replyInputContainer]:
|
|
235
|
+
[n.replyInputContainer]: u
|
|
236
236
|
}),
|
|
237
237
|
children: /* @__PURE__ */ i("div", { "data-tid": "action_add_argument", ref: H, children: /* @__PURE__ */ _("div", { className: n.argumentInputBox, children: [
|
|
238
|
-
a.length > 0 && A && (!
|
|
239
|
-
/* @__PURE__ */ i("div", { children:
|
|
238
|
+
a.length > 0 && A && (!u || !k) && /* @__PURE__ */ _("div", { className: n.userPosition, children: [
|
|
239
|
+
/* @__PURE__ */ i("div", { children: o.formatMessage({
|
|
240
240
|
id: "input.position",
|
|
241
241
|
defaultMessage: "Your position"
|
|
242
242
|
}) }),
|
|
243
243
|
/* @__PURE__ */ i(
|
|
244
244
|
Ze,
|
|
245
245
|
{
|
|
246
|
-
activeLabel:
|
|
246
|
+
activeLabel: l === a[0].id ? 0 : l === a[1].id ? 1 : null,
|
|
247
247
|
firstLabel: a[0],
|
|
248
248
|
secondLabel: a[1],
|
|
249
249
|
onChange: (e) => p(a[e].id)
|
|
@@ -255,7 +255,7 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
255
255
|
{
|
|
256
256
|
className: w(n.argumentTextInputBox, {
|
|
257
257
|
[n.argumentTextInputBoxisTablet]: !m,
|
|
258
|
-
[n.replyEditorRow]:
|
|
258
|
+
[n.replyEditorRow]: u
|
|
259
259
|
}),
|
|
260
260
|
children: [
|
|
261
261
|
/* @__PURE__ */ i(
|
|
@@ -263,22 +263,22 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
263
263
|
{
|
|
264
264
|
className: w(n.argumentAuthorContainer, {
|
|
265
265
|
[n.argumentAuthorContainerMobile]: m,
|
|
266
|
-
[n.argumentAuthorContainerActivated]: !m && C ||
|
|
266
|
+
[n.argumentAuthorContainerActivated]: !m && C || u
|
|
267
267
|
}),
|
|
268
|
-
children: !m && C ||
|
|
268
|
+
children: !m && C || u ? /* @__PURE__ */ i(
|
|
269
269
|
et,
|
|
270
270
|
{
|
|
271
|
-
avatarUrl:
|
|
272
|
-
userName:
|
|
271
|
+
avatarUrl: d.image_url,
|
|
272
|
+
userName: d.full_name,
|
|
273
273
|
size: me
|
|
274
274
|
}
|
|
275
275
|
) : /* @__PURE__ */ i(
|
|
276
276
|
tt,
|
|
277
277
|
{
|
|
278
|
-
fullName:
|
|
279
|
-
avatarUrl:
|
|
280
|
-
points:
|
|
281
|
-
slug:
|
|
278
|
+
fullName: d?.full_name || o.formatMessage({ id: "default_author.full_name" }),
|
|
279
|
+
avatarUrl: d?.image_url,
|
|
280
|
+
points: d?.points || 0,
|
|
281
|
+
slug: d?.hash_id
|
|
282
282
|
}
|
|
283
283
|
)
|
|
284
284
|
}
|
|
@@ -289,7 +289,7 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
289
289
|
onClick: R,
|
|
290
290
|
"data-testid": "argument-input",
|
|
291
291
|
className: w(n.textEditorBox, {
|
|
292
|
-
[n.replyTextEditorBox]:
|
|
292
|
+
[n.replyTextEditorBox]: u
|
|
293
293
|
}),
|
|
294
294
|
children: [
|
|
295
295
|
/* @__PURE__ */ i(
|
|
@@ -302,11 +302,11 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
302
302
|
Pe(e);
|
|
303
303
|
},
|
|
304
304
|
placeholder: he,
|
|
305
|
-
"aria-label":
|
|
305
|
+
"aria-label": o.formatMessage({
|
|
306
306
|
id: "input.argument_input.aria_label",
|
|
307
307
|
defaultMessage: "Message input field"
|
|
308
308
|
}),
|
|
309
|
-
onSubmit:
|
|
309
|
+
onSubmit: Le,
|
|
310
310
|
sources: V,
|
|
311
311
|
hideSourceAction: ge || g,
|
|
312
312
|
uid: `Argument${v}`,
|
|
@@ -315,7 +315,7 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
315
315
|
disabled: j || g || oe,
|
|
316
316
|
maxLength: g ? !1 : h?.actions?.argumentMaxLength,
|
|
317
317
|
disableRichText: h?.actions?.disableRichText || g,
|
|
318
|
-
shortBar:
|
|
318
|
+
shortBar: u,
|
|
319
319
|
hideSubmit: g,
|
|
320
320
|
allowedDomains: h?.allowed_sources,
|
|
321
321
|
active: F,
|
|
@@ -325,7 +325,7 @@ const it = Ye(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
325
325
|
),
|
|
326
326
|
B?.content && /* @__PURE__ */ i("div", { className: n.argumentInputWarning, children: B && Object.values(B).map((e, t) => /* @__PURE__ */ i("div", { children: e }, t)) }),
|
|
327
327
|
C && S?.find(
|
|
328
|
-
(e) => e.id ===
|
|
328
|
+
(e) => e.id === l
|
|
329
329
|
) && /* @__PURE__ */ _(
|
|
330
330
|
"div",
|
|
331
331
|
{
|