blixify-ui-web 1.2.212 → 1.2.214

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/components/data/dataTemplate/activityAttachments.d.ts +42 -0
  2. package/lib/components/data/dataTemplate/activityAttachments.d.ts.map +1 -0
  3. package/lib/components/data/dataTemplate/activityAttachments.js +214 -0
  4. package/lib/components/data/dataTemplate/activityAttachments.js.map +1 -0
  5. package/lib/components/data/dataTemplate/activityComposer.d.ts +21 -1
  6. package/lib/components/data/dataTemplate/activityComposer.d.ts.map +1 -1
  7. package/lib/components/data/dataTemplate/activityComposer.js +60 -16
  8. package/lib/components/data/dataTemplate/activityComposer.js.map +1 -1
  9. package/lib/components/data/dataTemplate/activityEmojiPicker.d.ts +16 -0
  10. package/lib/components/data/dataTemplate/activityEmojiPicker.d.ts.map +1 -0
  11. package/lib/components/data/dataTemplate/activityEmojiPicker.js +138 -0
  12. package/lib/components/data/dataTemplate/activityEmojiPicker.js.map +1 -0
  13. package/lib/components/data/dataTemplate/activityModal.d.ts.map +1 -1
  14. package/lib/components/data/dataTemplate/activityModal.js +416 -105
  15. package/lib/components/data/dataTemplate/activityModal.js.map +1 -1
  16. package/lib/components/data/dataTemplate/activityReactions.d.ts +49 -0
  17. package/lib/components/data/dataTemplate/activityReactions.d.ts.map +1 -0
  18. package/lib/components/data/dataTemplate/activityReactions.js +519 -0
  19. package/lib/components/data/dataTemplate/activityReactions.js.map +1 -0
  20. package/lib/components/data/dataTemplate/activityReplies.d.ts +35 -0
  21. package/lib/components/data/dataTemplate/activityReplies.d.ts.map +1 -0
  22. package/lib/components/data/dataTemplate/activityReplies.js +217 -0
  23. package/lib/components/data/dataTemplate/activityReplies.js.map +1 -0
  24. package/lib/components/data/dataTemplate/dataStateModel.d.ts +96 -0
  25. package/lib/components/data/dataTemplate/dataStateModel.d.ts.map +1 -1
  26. package/lib/components/data/dataTemplate/dataStateModel.js.map +1 -1
  27. package/lib/components/data/dataTemplate/index.d.ts.map +1 -1
  28. package/lib/components/data/dataTemplate/index.js +210 -187
  29. package/lib/components/data/dataTemplate/index.js.map +1 -1
  30. package/lib/tail.css +2 -2
  31. package/package.json +1 -1
@@ -95,6 +95,10 @@ var utils_1 = require("../utils");
95
95
  var activityComposer_1 = require("./activityComposer");
96
96
  var activityMentions_1 = require("./activityMentions");
97
97
  var activityChanges_1 = require("./activityChanges");
98
+ var modal_1 = require("../../display/modal");
99
+ var activityAttachments_1 = require("./activityAttachments");
100
+ var activityReplies_1 = require("./activityReplies");
101
+ var activityReactions_1 = require("./activityReactions");
98
102
  var select_1 = require("../../input/select");
99
103
  var activityRecords_1 = require("./activityRecords");
100
104
  var commentModel = [
@@ -128,31 +132,48 @@ var ActivityModal = function (props) {
128
132
  };
129
133
  exports.ActivityModal = ActivityModal;
130
134
  var ActivityPanel = function (props) {
131
- var _a, _b, _c, _d, _e, _f, _g;
135
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
132
136
  var config = props.activityLog;
133
137
  var commentsEnabled = !!((config === null || config === void 0 ? void 0 : config.enableComments) && config.commentCollectionId);
134
138
  var logsEnabled = !!((config === null || config === void 0 ? void 0 : config.enableLogs) && config.logsCollectionId);
135
- var _h = (0, react_1.useState)((_a = props.initialTab) !== null && _a !== void 0 ? _a : (commentsEnabled ? "comments" : "logs")), tab = _h[0], setTab = _h[1];
136
- var _j = (0, react_1.useState)("all"), logType = _j[0], setLogType = _j[1];
139
+ var _l = (0, react_1.useState)((_a = props.initialTab) !== null && _a !== void 0 ? _a : (commentsEnabled ? "comments" : "logs")), tab = _l[0], setTab = _l[1];
140
+ var _m = (0, react_1.useState)("all"), logType = _m[0], setLogType = _m[1];
137
141
  var activeTab = tab === "comments" && commentsEnabled
138
142
  ? "comments"
139
143
  : logsEnabled
140
144
  ? "logs"
141
145
  : "comments";
142
- var _k = (0, react_1.useState)(""), draft = _k[0], setDraft = _k[1];
143
- var _l = (0, react_1.useState)([]), mentions = _l[0], setMentions = _l[1];
144
- var _m = (0, react_1.useState)(null), editing = _m[0], setEditing = _m[1];
145
- var _o = (0, react_1.useState)(""), deleteId = _o[0], setDeleteId = _o[1];
146
- var _p = (0, react_1.useState)(false), busy = _p[0], setBusy = _p[1];
147
- var _q = (0, react_1.useState)(""), error = _q[0], setError = _q[1];
148
- var _r = (0, react_1.useState)(""), notice = _r[0], setNotice = _r[1];
149
- var _s = (0, react_1.useState)(null), pendingPing = _s[0], setPendingPing = _s[1];
150
- var _t = (0, react_1.useState)({}), authors = _t[0], setAuthors = _t[1];
151
- var _u = (0, react_1.useState)([]), authorIds = _u[0], setAuthorIds = _u[1];
152
- var _v = (0, react_1.useState)(null), rowCount = _v[0], setRowCount = _v[1];
153
- var _w = (0, react_1.useState)(true), listLoading = _w[0], setListLoading = _w[1];
154
- var _x = (0, react_1.useState)([]), recordIds = _x[0], setRecordIds = _x[1];
155
- var _y = (0, react_1.useState)(""), recordFilter = _y[0], setRecordFilter = _y[1];
146
+ var _o = (0, react_1.useState)(""), draft = _o[0], setDraft = _o[1];
147
+ var _p = (0, react_1.useState)([]), mentions = _p[0], setMentions = _p[1];
148
+ var _q = (0, react_1.useState)(null), editing = _q[0], setEditing = _q[1];
149
+ var _r = (0, react_1.useState)(""), deleteId = _r[0], setDeleteId = _r[1];
150
+ var _s = (0, react_1.useState)(false), busy = _s[0], setBusy = _s[1];
151
+ var _t = (0, react_1.useState)(""), error = _t[0], setError = _t[1];
152
+ var _u = (0, react_1.useState)(""), notice = _u[0], setNotice = _u[1];
153
+ // INFO: notifications that failed to send. A mention and a reply are
154
+ // delivered, retried and worded the same way, so one list holds both.
155
+ var _v = (0, react_1.useState)([]), pendingPings = _v[0], setPendingPings = _v[1];
156
+ var pendingPing = pendingPings.length > 0;
157
+ // INFO: files picked for the comment being written wait here and upload only
158
+ // when it is sent; keptAttachments are the files an edited comment already has
159
+ var _w = (0, react_1.useState)([]), pendingFiles = _w[0], setPendingFiles = _w[1];
160
+ var _x = (0, react_1.useState)([]), keptAttachments = _x[0], setKeptAttachments = _x[1];
161
+ var _y = (0, react_1.useState)(""), attachmentError = _y[0], setAttachmentError = _y[1];
162
+ var _z = (0, react_1.useState)(""), busyLabel = _z[0], setBusyLabel = _z[1];
163
+ var _0 = (0, react_1.useState)(null), deleteRecord = _0[0], setDeleteRecord = _0[1];
164
+ var _1 = (0, react_1.useState)([]), commentIds = _1[0], setCommentIds = _1[1];
165
+ // INFO: the comments on the page now, by id, so a reply's quote and a jump
166
+ // to the original need no request when the original is on the same page
167
+ var _2 = (0, react_1.useState)({}), pageComments = _2[0], setPageComments = _2[1];
168
+ var _3 = (0, react_1.useState)(null), replyTo = _3[0], setReplyTo = _3[1];
169
+ var _4 = (0, react_1.useState)(""), highlightId = _4[0], setHighlightId = _4[1];
170
+ var _5 = (0, react_1.useState)(null), quoteView = _5[0], setQuoteView = _5[1];
171
+ var _6 = (0, react_1.useState)({}), authors = _6[0], setAuthors = _6[1];
172
+ var _7 = (0, react_1.useState)([]), authorIds = _7[0], setAuthorIds = _7[1];
173
+ var _8 = (0, react_1.useState)(null), rowCount = _8[0], setRowCount = _8[1];
174
+ var _9 = (0, react_1.useState)(true), listLoading = _9[0], setListLoading = _9[1];
175
+ var _10 = (0, react_1.useState)([]), recordIds = _10[0], setRecordIds = _10[1];
176
+ var _11 = (0, react_1.useState)(""), recordFilter = _11[0], setRecordFilter = _11[1];
156
177
  var activeRecordId = props.dataId || recordFilter;
157
178
  var titleColumn = (_c = (_b = config === null || config === void 0 ? void 0 : config.recordTitleColumn) !== null && _b !== void 0 ? _b : props.recordTitleColumn) !== null && _c !== void 0 ? _c : "title";
158
179
  var recordScope = (_d = props.recordQuery) !== null && _d !== void 0 ? _d : [];
@@ -164,6 +185,46 @@ var ActivityPanel = function (props) {
164
185
  var mounted = (0, react_1.useRef)(true);
165
186
  var members = props.devSettings.organisationMembers;
166
187
  var isComments = activeTab === "comments";
188
+ var attachmentsConfig = config === null || config === void 0 ? void 0 : config.attachments;
189
+ var attachmentLimits = {
190
+ maxFiles: (_e = attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.maxFiles) !== null && _e !== void 0 ? _e : activityAttachments_1.ACTIVITY_ATTACHMENT_MAX_FILES,
191
+ maxBytes: (_f = attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.maxBytes) !== null && _f !== void 0 ? _f : activityAttachments_1.ACTIVITY_ATTACHMENT_MAX_BYTES,
192
+ };
193
+ var reactionsEnabled = !!(commentsEnabled &&
194
+ (config === null || config === void 0 ? void 0 : config.enableReactions) &&
195
+ config.reactionCollectionId &&
196
+ config.currentUserId);
197
+ var reactionEmojis = ((_g = config === null || config === void 0 ? void 0 : config.reactionEmojis) === null || _g === void 0 ? void 0 : _g.length)
198
+ ? config.reactionEmojis
199
+ : activityReactions_1.DEFAULT_REACTION_EMOJIS;
200
+ var reactions = (0, activityReactions_1.useActivityReactions)({
201
+ enabled: reactionsEnabled && activeTab === "comments",
202
+ devSettings: props.devSettings,
203
+ reactionCollectionId: config === null || config === void 0 ? void 0 : config.reactionCollectionId,
204
+ collectionId: props.collectionId,
205
+ currentUserId: config === null || config === void 0 ? void 0 : config.currentUserId,
206
+ commentIds: commentIds,
207
+ onError: function (message) { return setError(message); },
208
+ });
209
+ var repliesEnabled = !!(commentsEnabled && (config === null || config === void 0 ? void 0 : config.enableReplies));
210
+ var quotes = (0, activityReplies_1.useActivityQuotes)({
211
+ enabled: repliesEnabled && activeTab === "comments",
212
+ devSettings: props.devSettings,
213
+ commentCollectionId: config === null || config === void 0 ? void 0 : config.commentCollectionId,
214
+ collectionId: props.collectionId,
215
+ known: pageComments,
216
+ ids: Object.values(pageComments)
217
+ .map(function (each) { var _a; return (_a = each === null || each === void 0 ? void 0 : each.replyTo) === null || _a === void 0 ? void 0 : _a.commentId; })
218
+ .filter(function (each) { return typeof each === "string" && !!each; }),
219
+ });
220
+ var quotedComments = __assign(__assign({}, quotes.fetched), pageComments);
221
+ var quoteUserIds = Object.values(quotedComments)
222
+ .map(function (each) { return each === null || each === void 0 ? void 0 : each.userId; })
223
+ .filter(function (each) { return typeof each === "string" && !!each; });
224
+ var reactionUserIds = Array.from(new Set(Object.values(reactions.byComment).flatMap(function (list) {
225
+ return list.map(function (reaction) { return reaction.userId; });
226
+ })));
227
+ var nameIdsKey = JSON.stringify(Array.from(new Set(__spreadArray(__spreadArray(__spreadArray([], authorIds, true), reactionUserIds, true), quoteUserIds, true))));
167
228
  var collectionId = isComments
168
229
  ? config === null || config === void 0 ? void 0 : config.commentCollectionId
169
230
  : config === null || config === void 0 ? void 0 : config.logsCollectionId;
@@ -182,7 +243,7 @@ var ActivityPanel = function (props) {
182
243
  case 0:
183
244
  if (!(config === null || config === void 0 ? void 0 : config.userAPIEndpoint))
184
245
  return [2 /*return*/];
185
- missing = authorIds.filter(function (id) { return !authors[id] && !(members === null || members === void 0 ? void 0 : members.some(function (member) { return member.key === id; })); });
246
+ missing = JSON.parse(nameIdsKey).filter(function (id) { return !authors[id] && !(members === null || members === void 0 ? void 0 : members.some(function (member) { return member.key === id; })); });
186
247
  return [4 /*yield*/, Promise.all(missing.map(function (id) { return __awaiter(void 0, void 0, void 0, function () {
187
248
  var response, data, _a;
188
249
  var _b, _c;
@@ -218,7 +279,7 @@ var ActivityPanel = function (props) {
218
279
  return function () {
219
280
  cancelled = true;
220
281
  };
221
- }, [authorIds, authors, members, config === null || config === void 0 ? void 0 : config.userAPIEndpoint]);
282
+ }, [nameIdsKey, authors, members, config === null || config === void 0 ? void 0 : config.userAPIEndpoint]);
222
283
  var handleAuthorName = function (id) {
223
284
  var _a;
224
285
  return ((_a = members === null || members === void 0 ? void 0 : members.find(function (member) { return member.key === id; })) === null || _a === void 0 ? void 0 : _a.label) ||
@@ -230,7 +291,59 @@ var ActivityPanel = function (props) {
230
291
  setDraft("");
231
292
  setMentions([]);
232
293
  setEditing(null);
294
+ setPendingFiles([]);
295
+ setKeptAttachments([]);
296
+ setAttachmentError("");
297
+ setReplyTo(null);
233
298
  };
299
+ // INFO: Edit belongs to a comment's author and Delete to them and to the
300
+ // people allowed to moderate. A comment with no author is open to everyone,
301
+ // and so is every comment when the current person is not known. The backend
302
+ // is what enforces this; the buttons just do not offer what it would refuse.
303
+ var handleIsOwnComment = function (record) {
304
+ return !(record === null || record === void 0 ? void 0 : record.userId) ||
305
+ !(config === null || config === void 0 ? void 0 : config.currentUserId) ||
306
+ record.userId === config.currentUserId;
307
+ };
308
+ var handleJumpToComment = function (commentId) {
309
+ var _a;
310
+ var element = document.getElementById("activity-comment-".concat(commentId));
311
+ if (element) {
312
+ (_a = element.scrollIntoView) === null || _a === void 0 ? void 0 : _a.call(element, { block: "center", behavior: "smooth" });
313
+ setHighlightId(commentId);
314
+ setTimeout(function () {
315
+ if (mounted.current)
316
+ setHighlightId("");
317
+ }, 2000);
318
+ return;
319
+ }
320
+ // INFO: the feed is paged, so an original on another page opens in a
321
+ // window instead of loading pages until it turns up
322
+ var original = quotedComments[commentId];
323
+ if (original)
324
+ setQuoteView(original);
325
+ };
326
+ var handlePickFiles = function (picked) {
327
+ var next = (0, activityAttachments_1.handleAddAttachmentFiles)(pendingFiles, picked, keptAttachments.length, attachmentLimits);
328
+ setPendingFiles(next.files);
329
+ setAttachmentError(next.error);
330
+ };
331
+ // INFO: best effort — a file that cannot be removed is left, never an error
332
+ var handleRemoveFiles = function (files, context) { return __awaiter(void 0, void 0, void 0, function () {
333
+ return __generator(this, function (_a) {
334
+ switch (_a.label) {
335
+ case 0:
336
+ if (!(attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.remove) || !files.length)
337
+ return [2 /*return*/];
338
+ return [4 /*yield*/, Promise.allSettled(files.map(function (each) { return __awaiter(void 0, void 0, void 0, function () { var _a; return __generator(this, function (_b) {
339
+ return [2 /*return*/, (_a = attachmentsConfig.remove) === null || _a === void 0 ? void 0 : _a.call(attachmentsConfig, each, context)];
340
+ }); }); }))];
341
+ case 1:
342
+ _a.sent();
343
+ return [2 /*return*/];
344
+ }
345
+ });
346
+ }); };
234
347
  var handleWrite = function (type, data) { return __awaiter(void 0, void 0, void 0, function () {
235
348
  var query, result;
236
349
  var _a;
@@ -254,80 +367,167 @@ var ActivityPanel = function (props) {
254
367
  }
255
368
  });
256
369
  }); };
257
- var handleNotify = function (event) { return __awaiter(void 0, void 0, void 0, function () {
258
- var _a;
259
- return __generator(this, function (_b) {
260
- switch (_b.label) {
370
+ // INFO: sends each notification through the app's callback. Those that fail
371
+ // are kept for a retry that repeats only the delivery, never the comment write.
372
+ var handleNotify = function (pings) { return __awaiter(void 0, void 0, void 0, function () {
373
+ var failed, _i, pings_1, ping, _a, handleName;
374
+ var _b, _c;
375
+ return __generator(this, function (_d) {
376
+ switch (_d.label) {
261
377
  case 0:
262
- if (!(config === null || config === void 0 ? void 0 : config.onMention) || !event.mentionedUserIds.length)
378
+ if (!pings.length)
263
379
  return [2 /*return*/];
264
- _b.label = 1;
380
+ failed = [];
381
+ _i = 0, pings_1 = pings;
382
+ _d.label = 1;
265
383
  case 1:
266
- _b.trys.push([1, 3, , 4]);
267
- return [4 /*yield*/, config.onMention(event)];
384
+ if (!(_i < pings_1.length)) return [3 /*break*/, 9];
385
+ ping = pings_1[_i];
386
+ _d.label = 2;
268
387
  case 2:
269
- _b.sent();
270
- if (mounted.current) {
271
- setPendingPing(null);
272
- setNotice("Comment saved and mention notifications sent.");
273
- }
274
- return [3 /*break*/, 4];
388
+ _d.trys.push([2, 7, , 8]);
389
+ if (!(ping.kind === "mention")) return [3 /*break*/, 4];
390
+ return [4 /*yield*/, ((_b = config === null || config === void 0 ? void 0 : config.onMention) === null || _b === void 0 ? void 0 : _b.call(config, ping.event))];
275
391
  case 3:
276
- _a = _b.sent();
277
- if (mounted.current) {
278
- setPendingPing(event);
279
- setNotice("Comment saved, but mention notifications could not be sent. Retry notifications without posting again.");
280
- }
281
- return [3 /*break*/, 4];
282
- case 4: return [2 /*return*/];
392
+ _d.sent();
393
+ return [3 /*break*/, 6];
394
+ case 4: return [4 /*yield*/, ((_c = config === null || config === void 0 ? void 0 : config.onReply) === null || _c === void 0 ? void 0 : _c.call(config, ping.event))];
395
+ case 5:
396
+ _d.sent();
397
+ _d.label = 6;
398
+ case 6: return [3 /*break*/, 8];
399
+ case 7:
400
+ _a = _d.sent();
401
+ failed.push(ping);
402
+ return [3 /*break*/, 8];
403
+ case 8:
404
+ _i++;
405
+ return [3 /*break*/, 1];
406
+ case 9:
407
+ if (!mounted.current)
408
+ return [2 /*return*/];
409
+ setPendingPings(failed);
410
+ handleName = function (list) {
411
+ return Array.from(new Set(list.map(function (each) { return each.kind; })))
412
+ .sort()
413
+ .join(" and ");
414
+ };
415
+ setNotice(failed.length
416
+ ? "Comment saved, but ".concat(handleName(failed), " notifications could not be sent. Retry notifications without posting again.")
417
+ : "Comment saved and ".concat(handleName(pings), " notifications sent."));
418
+ return [2 /*return*/];
283
419
  }
284
420
  });
285
421
  }); };
286
422
  var handleSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
287
- var commentId, savedMentions, mentionedUserIds, userId, comment, result, savedId, recipients, _a;
288
- var _b;
289
- var _c, _d, _e, _f, _g, _h, _j, _k, _l;
290
- return __generator(this, function (_m) {
291
- switch (_m.label) {
423
+ var waiting, kept, commentId, itemId, answered, attachmentContext, uploaded, _i, waiting_1, file, _a, _b, _c, savedMentions, mentionedUserIds, userId, attachments, comment, result, err_1, dropped, savedId, recipients, replyRecipient, unconnected, pings, _d;
424
+ var _e;
425
+ var _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
426
+ return __generator(this, function (_u) {
427
+ switch (_u.label) {
292
428
  case 0:
293
- if (saving.current || !draft.trim() || !commentsEnabled || pendingPing)
429
+ waiting = pendingFiles;
430
+ kept = keptAttachments;
431
+ if (saving.current ||
432
+ (!draft.trim() && !waiting.length && !kept.length) ||
433
+ !commentsEnabled ||
434
+ pendingPing)
294
435
  return [2 /*return*/];
295
436
  saving.current = true;
296
437
  setBusy(true);
297
438
  setError("");
298
439
  setNotice("");
299
- commentId = (_d = (_c = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _c !== void 0 ? _c : editing === null || editing === void 0 ? void 0 : editing.id) !== null && _d !== void 0 ? _d : (0, uuid_1.v4)();
440
+ commentId = (_g = (_f = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _f !== void 0 ? _f : editing === null || editing === void 0 ? void 0 : editing.id) !== null && _g !== void 0 ? _g : (0, uuid_1.v4)();
441
+ itemId = editing
442
+ ? ((_h = editing.itemId) !== null && _h !== void 0 ? _h : null)
443
+ : replyTo
444
+ ? replyTo.itemId
445
+ : activeRecordId || null;
446
+ answered = editing ? null : replyTo;
447
+ attachmentContext = {
448
+ commentId: commentId,
449
+ collectionId: props.collectionId,
450
+ itemId: itemId,
451
+ };
452
+ uploaded = [];
453
+ if (!(waiting.length && attachmentsConfig)) return [3 /*break*/, 8];
454
+ _u.label = 1;
455
+ case 1:
456
+ _u.trys.push([1, 6, , 8]);
457
+ _i = 0, waiting_1 = waiting;
458
+ _u.label = 2;
459
+ case 2:
460
+ if (!(_i < waiting_1.length)) return [3 /*break*/, 5];
461
+ file = waiting_1[_i];
462
+ if (mounted.current)
463
+ setBusyLabel("Uploading ".concat(uploaded.length + 1, " of ").concat(waiting.length, "\u2026"));
464
+ _b = (_a = uploaded).push;
465
+ return [4 /*yield*/, attachmentsConfig.upload(file, attachmentContext)];
466
+ case 3:
467
+ _b.apply(_a, [_u.sent()]);
468
+ _u.label = 4;
469
+ case 4:
470
+ _i++;
471
+ return [3 /*break*/, 2];
472
+ case 5: return [3 /*break*/, 8];
473
+ case 6:
474
+ _c = _u.sent();
475
+ return [4 /*yield*/, handleRemoveFiles(uploaded, attachmentContext)];
476
+ case 7:
477
+ _u.sent();
478
+ saving.current = false;
479
+ if (mounted.current) {
480
+ setError("Could not upload ".concat((_k = (_j = waiting[uploaded.length]) === null || _j === void 0 ? void 0 : _j.name) !== null && _k !== void 0 ? _k : "a file", ". Nothing was saved; your comment and files are still here."));
481
+ setBusyLabel("");
482
+ setBusy(false);
483
+ }
484
+ return [2 /*return*/];
485
+ case 8:
300
486
  savedMentions = (0, activityMentions_1.handleValidMentions)(draft, mentions);
301
487
  mentionedUserIds = Array.from(new Set(savedMentions.map(function (mention) { return mention.userId; })));
302
- userId = (_f = (_e = editing === null || editing === void 0 ? void 0 : editing.userId) !== null && _e !== void 0 ? _e : config === null || config === void 0 ? void 0 : config.currentUserId) !== null && _f !== void 0 ? _f : null;
303
- comment = __assign({ comment: draft, mentions: savedMentions, mentionedUserIds: mentionedUserIds, userId: userId, collectionId: props.collectionId, itemId: editing ? ((_g = editing.itemId) !== null && _g !== void 0 ? _g : null) : activeRecordId || null }, (editing
488
+ userId = editing
489
+ ? ((_l = editing.userId) !== null && _l !== void 0 ? _l : null)
490
+ : ((_m = config === null || config === void 0 ? void 0 : config.currentUserId) !== null && _m !== void 0 ? _m : null);
491
+ attachments = __spreadArray(__spreadArray([], kept, true), uploaded, true);
492
+ comment = __assign(__assign(__assign(__assign({ comment: draft, mentions: savedMentions, mentionedUserIds: mentionedUserIds }, (editing ? {} : { userId: userId })), { collectionId: props.collectionId, itemId: itemId }), (attachmentsConfig || attachments.length ? { attachments: attachments } : {})), (editing
304
493
  ? { updatedAt: new Date() }
305
- : (_b = {},
306
- _b[(0, utils_1.parseServerId)(props.devSettings.server)] = commentId,
307
- _b.createdAt = new Date(),
308
- _b)));
309
- _m.label = 1;
310
- case 1:
311
- _m.trys.push([1, 4, 5, 6]);
494
+ : __assign((_e = {}, _e[(0, utils_1.parseServerId)(props.devSettings.server)] = commentId, _e.createdAt = new Date(), _e), (replyTo ? { replyTo: { commentId: replyTo.id } } : {}))));
495
+ _u.label = 9;
496
+ case 9:
497
+ _u.trys.push([9, 16, 17, 18]);
498
+ result = void 0;
499
+ _u.label = 10;
500
+ case 10:
501
+ _u.trys.push([10, 12, , 14]);
312
502
  return [4 /*yield*/, handleWrite(editing ? "update" : "create", {
313
503
  id: commentId,
314
504
  data: comment,
315
505
  })];
316
- case 2:
317
- result = _m.sent();
506
+ case 11:
507
+ result = _u.sent();
508
+ return [3 /*break*/, 14];
509
+ case 12:
510
+ err_1 = _u.sent();
511
+ return [4 /*yield*/, handleRemoveFiles(uploaded, attachmentContext)];
512
+ case 13:
513
+ _u.sent();
514
+ throw err_1;
515
+ case 14:
516
+ dropped = ((_o = editing === null || editing === void 0 ? void 0 : editing.attachments) !== null && _o !== void 0 ? _o : []).filter(function (each) { return !kept.some(function (keptFile) { return keptFile.path === each.path; }); });
517
+ handleRemoveFiles(dropped, attachmentContext);
318
518
  savedId = !editing && typeof result === "string"
319
519
  ? result
320
520
  : !editing && Array.isArray(result)
321
- ? ((_h = result[0]) !== null && _h !== void 0 ? _h : commentId)
521
+ ? ((_p = result[0]) !== null && _p !== void 0 ? _p : commentId)
322
522
  : commentId;
323
523
  // Notification delivery still runs if the panel was closed during the save.
324
524
  if (mounted.current) {
325
525
  handleResetDraft();
326
526
  // New comments sort onto page one; edits retain the reader's page.
327
527
  if (editing)
328
- (_j = listRef.current) === null || _j === void 0 ? void 0 : _j.handleRefreshCurrentPage();
528
+ (_q = listRef.current) === null || _q === void 0 ? void 0 : _q.handleRefreshCurrentPage();
329
529
  else
330
- (_k = listRef.current) === null || _k === void 0 ? void 0 : _k.handleRefresh();
530
+ (_r = listRef.current) === null || _r === void 0 ? void 0 : _r.handleRefresh();
331
531
  setNotice("Comment saved.");
332
532
  }
333
533
  recipients = mentionedUserIds.filter(function (id) {
@@ -335,62 +535,94 @@ var ActivityPanel = function (props) {
335
535
  return id !== (config === null || config === void 0 ? void 0 : config.currentUserId) &&
336
536
  !((_a = editing === null || editing === void 0 ? void 0 : editing.mentionedUserIds) !== null && _a !== void 0 ? _a : []).includes(id);
337
537
  });
338
- if (mounted.current && recipients.length && !(config === null || config === void 0 ? void 0 : config.onMention))
339
- setNotice("Comment saved. Mentions recorded; notifications are not connected.");
340
- return [4 /*yield*/, handleNotify({
341
- commentId: savedId,
342
- commentCollectionId: (_l = config === null || config === void 0 ? void 0 : config.commentCollectionId) !== null && _l !== void 0 ? _l : "",
343
- collectionId: props.collectionId,
344
- itemId: comment.itemId,
345
- comment: comment.comment,
346
- userId: userId,
347
- mentionedUserIds: recipients,
348
- })];
349
- case 3:
350
- _m.sent();
351
- return [3 /*break*/, 6];
352
- case 4:
353
- _a = _m.sent();
538
+ replyRecipient = (answered === null || answered === void 0 ? void 0 : answered.userId) && answered.userId !== (config === null || config === void 0 ? void 0 : config.currentUserId)
539
+ ? answered
540
+ : null;
541
+ unconnected = __spreadArray(__spreadArray([], (recipients.length && !(config === null || config === void 0 ? void 0 : config.onMention) ? ["Mentions"] : []), true), (replyRecipient && !(config === null || config === void 0 ? void 0 : config.onReply) ? ["Reply"] : []), true);
542
+ if (mounted.current && unconnected.length)
543
+ setNotice("Comment saved. ".concat(unconnected.join(" and "), " recorded; notifications are not connected."));
544
+ pings = [];
545
+ if ((config === null || config === void 0 ? void 0 : config.onMention) && recipients.length)
546
+ pings.push({
547
+ kind: "mention",
548
+ event: {
549
+ commentId: savedId,
550
+ commentCollectionId: (_s = config.commentCollectionId) !== null && _s !== void 0 ? _s : "",
551
+ collectionId: props.collectionId,
552
+ itemId: comment.itemId,
553
+ comment: comment.comment,
554
+ userId: userId,
555
+ mentionedUserIds: recipients,
556
+ },
557
+ });
558
+ if ((config === null || config === void 0 ? void 0 : config.onReply) && replyRecipient)
559
+ pings.push({
560
+ kind: "reply",
561
+ event: {
562
+ commentId: savedId,
563
+ commentCollectionId: (_t = config.commentCollectionId) !== null && _t !== void 0 ? _t : "",
564
+ collectionId: props.collectionId,
565
+ itemId: comment.itemId,
566
+ comment: comment.comment,
567
+ userId: userId,
568
+ replyToCommentId: replyRecipient.id,
569
+ replyToUserId: replyRecipient.userId,
570
+ },
571
+ });
572
+ return [4 /*yield*/, handleNotify(pings)];
573
+ case 15:
574
+ _u.sent();
575
+ return [3 /*break*/, 18];
576
+ case 16:
577
+ _d = _u.sent();
354
578
  if (mounted.current)
355
579
  setError("Could not save your comment. Your draft is still here; please try again.");
356
- return [3 /*break*/, 6];
357
- case 5:
580
+ return [3 /*break*/, 18];
581
+ case 17:
358
582
  saving.current = false;
359
- if (mounted.current)
583
+ if (mounted.current) {
584
+ setBusyLabel("");
360
585
  setBusy(false);
586
+ }
361
587
  return [7 /*endfinally*/];
362
- case 6: return [2 /*return*/];
588
+ case 18: return [2 /*return*/];
363
589
  }
364
590
  });
365
591
  }); };
366
592
  var handleDelete = function () { return __awaiter(void 0, void 0, void 0, function () {
367
593
  var _a;
368
- var _b, _c;
369
- return __generator(this, function (_d) {
370
- switch (_d.label) {
594
+ var _b, _c, _d, _e;
595
+ return __generator(this, function (_f) {
596
+ switch (_f.label) {
371
597
  case 0:
372
598
  if (saving.current || !deleteId)
373
599
  return [2 /*return*/];
374
600
  saving.current = true;
375
601
  setBusy(true);
376
602
  setError("");
377
- _d.label = 1;
603
+ _f.label = 1;
378
604
  case 1:
379
- _d.trys.push([1, 3, 4, 5]);
605
+ _f.trys.push([1, 3, 4, 5]);
380
606
  return [4 /*yield*/, handleWrite("delete", { id: deleteId })];
381
607
  case 2:
382
- _d.sent();
608
+ _f.sent();
609
+ handleRemoveFiles(((_b = deleteRecord === null || deleteRecord === void 0 ? void 0 : deleteRecord.attachments) !== null && _b !== void 0 ? _b : []), {
610
+ commentId: deleteId,
611
+ collectionId: props.collectionId,
612
+ itemId: (_c = deleteRecord === null || deleteRecord === void 0 ? void 0 : deleteRecord.itemId) !== null && _c !== void 0 ? _c : null,
613
+ });
383
614
  if (!mounted.current)
384
615
  return [2 /*return*/];
385
- if (((_b = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _b !== void 0 ? _b : editing === null || editing === void 0 ? void 0 : editing.id) === deleteId)
616
+ if (((_d = editing === null || editing === void 0 ? void 0 : editing._id) !== null && _d !== void 0 ? _d : editing === null || editing === void 0 ? void 0 : editing.id) === deleteId)
386
617
  handleResetDraft();
387
618
  setDeleteId("");
619
+ setDeleteRecord(null);
388
620
  setNotice("Comment deleted.");
389
621
  // Deleting the last row on a later page would hide the feed's paginator.
390
- (_c = listRef.current) === null || _c === void 0 ? void 0 : _c.handleRefresh();
622
+ (_e = listRef.current) === null || _e === void 0 ? void 0 : _e.handleRefresh();
391
623
  return [3 /*break*/, 5];
392
624
  case 3:
393
- _a = _d.sent();
625
+ _a = _f.sent();
394
626
  if (mounted.current)
395
627
  setError("Could not delete the comment. Please try again.");
396
628
  return [3 /*break*/, 5];
@@ -404,7 +636,7 @@ var ActivityPanel = function (props) {
404
636
  });
405
637
  }); };
406
638
  var renderComment = function (record) {
407
- var _a, _b;
639
+ var _a, _b, _c, _d, _e;
408
640
  var text = String((_a = record.comment) !== null && _a !== void 0 ? _a : "");
409
641
  var savedMentions = (0, activityMentions_1.handleValidMentions)(text, Array.isArray(record.mentions) ? record.mentions : []);
410
642
  var parts = [];
@@ -416,21 +648,48 @@ var ActivityPanel = function (props) {
416
648
  });
417
649
  parts.push(text.slice(cursor));
418
650
  var id = (_b = record._id) !== null && _b !== void 0 ? _b : record.id;
419
- return (react_1.default.createElement("div", { className: "space-y-2" },
420
- react_1.default.createElement("p", { className: "whitespace-pre-wrap break-words" }, parts),
651
+ var quoted = ((_c = record.replyTo) === null || _c === void 0 ? void 0 : _c.commentId)
652
+ ? quotedComments[String(record.replyTo.commentId)]
653
+ : undefined;
654
+ var canEdit = handleIsOwnComment(record);
655
+ var canDelete = canEdit || !!(config === null || config === void 0 ? void 0 : config.canModerate);
656
+ return (react_1.default.createElement("div", { id: id ? "activity-comment-".concat(id) : undefined, className: "space-y-2 rounded-md ".concat(highlightId && highlightId === String(id) ? "ring-2 ring-primary-300" : "") },
657
+ repliesEnabled && ((_d = record.replyTo) === null || _d === void 0 ? void 0 : _d.commentId) && (react_1.default.createElement(activityReplies_1.ActivityQuote, { name: quoted ? handleAuthorName(quoted.userId) : "Original comment", line: quoted ? (0, activityReplies_1.handleDescribeQuoteLine)(quoted) : "", deleted: !quoted && quotes.gone.includes(String(record.replyTo.commentId)), darkMode: props.darkMode, onOpen: function () { return handleJumpToComment(String(record.replyTo.commentId)); } })),
658
+ text && react_1.default.createElement("p", { className: "whitespace-pre-wrap break-words" }, parts),
659
+ Array.isArray(record.attachments) && record.attachments.length > 0 && (react_1.default.createElement(activityAttachments_1.ActivityAttachmentList, { attachments: record.attachments, getUrl: attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.getUrl, darkMode: props.darkMode })),
660
+ reactionsEnabled && id && (react_1.default.createElement(activityReactions_1.ActivityReactionBar, { summaries: (0, activityReactions_1.handleSummariseReactions)((_e = reactions.byComment[String(id)]) !== null && _e !== void 0 ? _e : [], config === null || config === void 0 ? void 0 : config.currentUserId), emojis: reactionEmojis, authorName: handleAuthorName, darkMode: props.darkMode, onToggle: function (emoji) {
661
+ var _a;
662
+ return reactions.handleToggle({ id: String(id), itemId: (_a = record.itemId) !== null && _a !== void 0 ? _a : null }, emoji);
663
+ } })),
421
664
  react_1.default.createElement("div", { className: "flex gap-3 text-xs text-gray-500" },
422
665
  record.updatedAt && react_1.default.createElement("span", null, "Edited"),
423
- react_1.default.createElement("button", { type: "button", disabled: busy || !!pendingPing, onClick: function (event) {
666
+ repliesEnabled && id && (react_1.default.createElement("button", { type: "button", disabled: busy || !!pendingPing, onClick: function (event) {
667
+ var _a, _b;
668
+ event.stopPropagation();
669
+ setEditing(null);
670
+ setReplyTo({
671
+ id: String(id),
672
+ userId: (_a = record.userId) !== null && _a !== void 0 ? _a : null,
673
+ itemId: (_b = record.itemId) !== null && _b !== void 0 ? _b : null,
674
+ name: handleAuthorName(record.userId),
675
+ line: (0, activityReplies_1.handleDescribeQuoteLine)(record),
676
+ });
677
+ } }, "Reply")),
678
+ canEdit && (react_1.default.createElement("button", { type: "button", disabled: busy || !!pendingPing, onClick: function (event) {
424
679
  event.stopPropagation();
425
680
  setEditing(record);
426
681
  setDraft(text);
427
682
  setMentions(savedMentions);
683
+ setKeptAttachments(Array.isArray(record.attachments) ? record.attachments : []);
684
+ setPendingFiles([]);
685
+ setAttachmentError("");
428
686
  setError("");
429
- } }, "Edit"),
430
- react_1.default.createElement("button", { type: "button", disabled: busy || !!pendingPing, onClick: function (event) {
687
+ } }, "Edit")),
688
+ canDelete && (react_1.default.createElement("button", { type: "button", disabled: busy || !!pendingPing, onClick: function (event) {
431
689
  event.stopPropagation();
432
690
  setDeleteId(id);
433
- } }, "Delete"))));
691
+ setDeleteRecord(record);
692
+ } }, "Delete")))));
434
693
  };
435
694
  var renderRecordTitle = function (record) {
436
695
  var _a;
@@ -474,7 +733,7 @@ var ActivityPanel = function (props) {
474
733
  { type: "=", queryId: "collectionId", value: props.collectionId }
475
734
  ], (activeRecordId
476
735
  ? [{ type: "=", queryId: "itemId", value: activeRecordId }]
477
- : []), true), ((_e = (isComments ? config === null || config === void 0 ? void 0 : config.commentQuery : config === null || config === void 0 ? void 0 : config.logQuery)) !== null && _e !== void 0 ? _e : []), true), (!isComments && logType !== "all"
736
+ : []), true), ((_h = (isComments ? config === null || config === void 0 ? void 0 : config.commentQuery : config === null || config === void 0 ? void 0 : config.logQuery)) !== null && _h !== void 0 ? _h : []), true), (!isComments && logType !== "all"
478
737
  ? [{ type: "=", queryId: "type", value: logType }]
479
738
  : []), true);
480
739
  var renderLoadingRows = function () { return (react_1.default.createElement("div", { "data-testid": "activity-loading", className: "space-y-3 py-4" }, Array.from({ length: 3 }).map(function (_, index) { return (react_1.default.createElement("div", { key: "activity-loading-".concat(index), className: "h-12 w-full rounded-lg animate-pulse ".concat(props.darkMode ? "bg-gray-700" : "bg-gray-200") })); }))); };
@@ -487,7 +746,7 @@ var ActivityPanel = function (props) {
487
746
  setTab(nextTab);
488
747
  } }),
489
748
  react_1.default.createElement("span", { className: "text-xs text-gray-500" }, activeRecordId
490
- ? "Activity for ".concat((_f = recordTitles[activeRecordId]) !== null && _f !== void 0 ? _f : activeRecordId)
749
+ ? "Activity for ".concat((_j = recordTitles[activeRecordId]) !== null && _j !== void 0 ? _j : activeRecordId)
491
750
  : "All activity in ".concat(props.title))),
492
751
  !props.dataId && (react_1.default.createElement("div", null,
493
752
  react_1.default.createElement(select_1.Select, { id: "activity-record-filter", label: "Filter by data", value: recordFilter, darkMode: props.darkMode, disabled: busy || !!pendingPing, options: __spreadArray(__spreadArray([
@@ -497,13 +756,13 @@ var ActivityPanel = function (props) {
497
756
  ? [
498
757
  {
499
758
  key: recordFilter,
500
- label: (_g = recordTitles[recordFilter]) !== null && _g !== void 0 ? _g : recordFilter,
759
+ label: (_k = recordTitles[recordFilter]) !== null && _k !== void 0 ? _k : recordFilter,
501
760
  },
502
761
  ]
503
762
  : []), true), onSearch: recordSearch.setSearch, onChange: function (id) {
504
763
  if (id === recordFilter)
505
764
  return;
506
- if (draft.trim() &&
765
+ if ((draft.trim() || pendingFiles.length > 0) &&
507
766
  !window.confirm("Discard this comment draft and change the data filter?"))
508
767
  return;
509
768
  handleResetDraft();
@@ -537,7 +796,7 @@ var ActivityPanel = function (props) {
537
796
  return [2 /*return*/];
538
797
  saving.current = true;
539
798
  setBusy(true);
540
- return [4 /*yield*/, handleNotify(pendingPing)];
799
+ return [4 /*yield*/, handleNotify(pendingPings)];
541
800
  case 1:
542
801
  _a.sent();
543
802
  saving.current = false;
@@ -548,17 +807,49 @@ var ActivityPanel = function (props) {
548
807
  });
549
808
  }); } }, "Retry notifications"),
550
809
  react_1.default.createElement("button", { type: "button", disabled: busy, onClick: function () {
551
- setPendingPing(null);
810
+ setPendingPings([]);
552
811
  setNotice("Comment saved. Notification retry dismissed.");
553
812
  } }, "Dismiss"))))),
554
- isComments && (react_1.default.createElement(activityComposer_1.ActivityComposer, { value: draft, mentions: mentions, members: members !== null && members !== void 0 ? members : [], darkMode: props.darkMode, busy: busy || !!pendingPing, editing: !!editing, onChange: function (value, selectedMentions) {
813
+ isComments && (react_1.default.createElement(activityComposer_1.ActivityComposer, { value: draft, mentions: mentions, members: members !== null && members !== void 0 ? members : [], darkMode: props.darkMode, busy: busy || !!pendingPing, editing: !!editing, busyLabel: busyLabel || undefined, replyingTo: replyTo ? { name: replyTo.name, line: replyTo.line } : undefined, onCancelReply: function () { return setReplyTo(null); }, focusToken: replyTo === null || replyTo === void 0 ? void 0 : replyTo.id, attachments: attachmentsConfig
814
+ ? {
815
+ files: pendingFiles,
816
+ existing: keptAttachments,
817
+ error: attachmentError,
818
+ maxFiles: attachmentLimits.maxFiles,
819
+ onPick: handlePickFiles,
820
+ onRemoveFile: function (index) {
821
+ setPendingFiles(function (previous) {
822
+ return previous.filter(function (_, each) { return each !== index; });
823
+ });
824
+ setAttachmentError("");
825
+ },
826
+ onRemoveExisting: function (index) {
827
+ return setKeptAttachments(function (previous) {
828
+ return previous.filter(function (_, each) { return each !== index; });
829
+ });
830
+ },
831
+ }
832
+ : undefined, onChange: function (value, selectedMentions) {
555
833
  setDraft(value);
556
834
  setMentions(selectedMentions);
557
835
  }, onSubmit: handleSubmit, onCancel: handleResetDraft })),
558
836
  deleteId && (react_1.default.createElement("div", { role: "alert", className: "flex flex-wrap items-center gap-3 rounded-lg border border-red-200 p-3 text-sm" },
559
837
  react_1.default.createElement("span", null, "Delete this comment?"),
560
838
  react_1.default.createElement("button", { type: "button", disabled: busy, className: "font-medium text-red-500", onClick: handleDelete }, "Confirm delete"),
561
- react_1.default.createElement("button", { type: "button", disabled: busy, onClick: function () { return setDeleteId(""); } }, "Cancel"))),
839
+ react_1.default.createElement("button", { type: "button", disabled: busy, onClick: function () {
840
+ setDeleteId("");
841
+ setDeleteRecord(null);
842
+ } }, "Cancel"))),
843
+ react_1.default.createElement(modal_1.Modal, { open: !!quoteView, title: "Original comment", maxWidth: "2xl", darkMode: props.darkMode, onClose: function () { return setQuoteView(null); }, renderContent: function () {
844
+ return quoteView ? (react_1.default.createElement("div", { className: "space-y-2" },
845
+ react_1.default.createElement("p", { className: "text-sm font-medium" },
846
+ handleAuthorName(quoteView.userId),
847
+ quoteView.createdAt &&
848
+ (0, dayjs_1.default)(quoteView.createdAt).isValid() && (react_1.default.createElement("span", { className: "ml-2 text-xs font-normal text-gray-500" }, (0, dayjs_1.default)(quoteView.createdAt).format("MMM D, HH:mm")))),
849
+ quoteView.comment && (react_1.default.createElement("p", { className: "whitespace-pre-wrap break-words text-sm" }, String(quoteView.comment))),
850
+ Array.isArray(quoteView.attachments) &&
851
+ quoteView.attachments.length > 0 && (react_1.default.createElement(activityAttachments_1.ActivityAttachmentList, { attachments: quoteView.attachments, getUrl: attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.getUrl, darkMode: props.darkMode })))) : null;
852
+ } }),
562
853
  react_1.default.createElement(dataWrapper_1.DataTemplateWrapper, { key: JSON.stringify([activeTab, filters]), ref: listRef, title: "", type: "list", collectionId: collectionId !== null && collectionId !== void 0 ? collectionId : "", schema: isComments ? commentModel : logsModel, workspace: {
563
854
  apiEndpoint: props.devSettings.dbEndpoint,
564
855
  apiEndpointType: props.devSettings.server,
@@ -575,6 +866,26 @@ var ActivityPanel = function (props) {
575
866
  bareListHandleData: function (records) {
576
867
  var _a;
577
868
  setRowCount(records.length);
869
+ if (isComments) {
870
+ var byId_1 = {};
871
+ records.forEach(function (record) {
872
+ var _a;
873
+ byId_1[String((_a = record._id) !== null && _a !== void 0 ? _a : record.id)] = record;
874
+ });
875
+ setPageComments(function (previous) {
876
+ return JSON.stringify(previous) === JSON.stringify(byId_1)
877
+ ? previous
878
+ : byId_1;
879
+ });
880
+ var ids_1 = records
881
+ .map(function (record) { var _a, _b; return String((_b = (_a = record._id) !== null && _a !== void 0 ? _a : record.id) !== null && _b !== void 0 ? _b : ""); })
882
+ .filter(Boolean);
883
+ setCommentIds(function (previous) {
884
+ return JSON.stringify(previous) === JSON.stringify(ids_1)
885
+ ? previous
886
+ : ids_1;
887
+ });
888
+ }
578
889
  var itemIds = Array.from(new Set(records.map(function (record) { return record.itemId; }).filter(Boolean)));
579
890
  setRecordIds(function (previous) {
580
891
  return JSON.stringify(previous) === JSON.stringify(itemIds)