@unhingged/vizu-core 0.1.16 → 0.1.17
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/auto.cjs +22 -3
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.js +22 -3
- package/dist/auto.js.map +1 -1
- package/dist/index.cjs +22 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +22 -3
- package/dist/index.js.map +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js.map +1 -1
- package/dist/vizu.min.js +6 -6
- package/dist/vizu.min.js.map +1 -1
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -86,6 +86,9 @@ function renderAttachmentsHtml(attachments) {
|
|
|
86
86
|
function migrateComment(raw) {
|
|
87
87
|
if (!raw || typeof raw !== "object") return raw;
|
|
88
88
|
const next = { ...raw };
|
|
89
|
+
if (next.id == null && next._id != null) {
|
|
90
|
+
next.id = next._id;
|
|
91
|
+
}
|
|
89
92
|
if (!Array.isArray(next.fingerprints) || next.fingerprints.length === 0) {
|
|
90
93
|
if (next.fingerprint) {
|
|
91
94
|
next.fingerprints = [next.fingerprint];
|
|
@@ -4281,10 +4284,26 @@ var Vizu = class {
|
|
|
4281
4284
|
this.refreshUi();
|
|
4282
4285
|
}
|
|
4283
4286
|
async removeComment(id) {
|
|
4284
|
-
const
|
|
4285
|
-
if (
|
|
4287
|
+
const idx = this.comments.findIndex((c) => c.id === id);
|
|
4288
|
+
if (idx === -1) return;
|
|
4289
|
+
const comment = this.comments[idx];
|
|
4286
4290
|
this.comments = this.comments.filter((c) => c.id !== id);
|
|
4287
|
-
|
|
4291
|
+
try {
|
|
4292
|
+
await this.storage.removeComment(this.opts.namespace, id);
|
|
4293
|
+
} catch (err) {
|
|
4294
|
+
this.comments.splice(idx, 0, comment);
|
|
4295
|
+
const status = err?.status;
|
|
4296
|
+
const code = err?.code ?? "";
|
|
4297
|
+
const msg = status === 403 || code === "forbidden" ? "Delete failed \u2014 you don't have permission." : status === 401 || code === "auth_required" ? "Delete failed \u2014 please sign in again." : "Delete failed. Please try again.";
|
|
4298
|
+
this.pill?.toast(msg);
|
|
4299
|
+
if (this.popover?.isOpen()) {
|
|
4300
|
+
const anchors = this.popover.getAnchors();
|
|
4301
|
+
if (anchors[0]) this.popover.update(this.commentsForElement(anchors[0]));
|
|
4302
|
+
}
|
|
4303
|
+
this.refreshUi();
|
|
4304
|
+
if (typeof console !== "undefined") console.warn("[vizu] removeComment failed", err);
|
|
4305
|
+
return;
|
|
4306
|
+
}
|
|
4288
4307
|
this.bus.emit("comment:removed", { id, comment });
|
|
4289
4308
|
if (this.popover?.isOpen()) {
|
|
4290
4309
|
const anchors = this.popover.getAnchors();
|