pollcatch 2.1.12 → 2.1.13
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/package.json +1 -1
- package/pc.js +7 -6
package/package.json
CHANGED
package/pc.js
CHANGED
|
@@ -1107,8 +1107,9 @@ function Ao(e, t = 50) {
|
|
|
1107
1107
|
return e.length <= t ? e : e.substring(0, t).trim() + "...";
|
|
1108
1108
|
}
|
|
1109
1109
|
class _o {
|
|
1110
|
+
// Tracks if user has ever made a selection (even if later deselected)
|
|
1110
1111
|
constructor(t) {
|
|
1111
|
-
this.stats = O(), this.localStats = O(), this.isLoading = !0, this.isSubmitting = !1, (this.host = t).addController(this);
|
|
1112
|
+
this.stats = O(), this.localStats = O(), this.isLoading = !0, this.isSubmitting = !1, this.hasInteracted = !1, (this.host = t).addController(this);
|
|
1112
1113
|
}
|
|
1113
1114
|
hostConnected() {
|
|
1114
1115
|
this.loadStats();
|
|
@@ -1239,7 +1240,7 @@ class _o {
|
|
|
1239
1240
|
*/
|
|
1240
1241
|
updateStats(t, o) {
|
|
1241
1242
|
const r = this.host;
|
|
1242
|
-
if (this.stats && (this.stats = $o(this.stats, this.localStats)), this.localStats = {
|
|
1243
|
+
if (this.hasInteracted = !0, this.stats && (this.stats = $o(this.stats, this.localStats)), this.localStats = {
|
|
1243
1244
|
count: t > 0 || r.type === $.nps ? 1 : 0,
|
|
1244
1245
|
// always 1 or 0
|
|
1245
1246
|
sum: t,
|
|
@@ -1260,7 +1261,7 @@ class _o {
|
|
|
1260
1261
|
this.localStats.submitted = (/* @__PURE__ */ new Date()).toISOString(), await this.persistLocalStats(), this.host.requestUpdate();
|
|
1261
1262
|
}
|
|
1262
1263
|
async submitStats() {
|
|
1263
|
-
if (!this.hasLocalStats())
|
|
1264
|
+
if (!this.hasLocalStats() && !this.hasInteracted)
|
|
1264
1265
|
throw m.warn("No local stats to submit"), new Error("No local stats to submit");
|
|
1265
1266
|
const t = this.host, o = Math.floor(Date.now() / 1e3).toString(), r = await re(), s = await this.getProjectId(), i = t.name || "", a = this.localStats.sum, n = Object.keys(this.localStats.breakdown || {});
|
|
1266
1267
|
this.isSubmitting = !0, this.host.requestUpdate();
|
|
@@ -1462,18 +1463,18 @@ class Eo {
|
|
|
1462
1463
|
*/
|
|
1463
1464
|
shouldShowStats() {
|
|
1464
1465
|
const t = this.host;
|
|
1465
|
-
return t.showStats === void 0 || t.showStats === "never" ? !1 : t.showStats === "always" || t.showStats === "" || t.readOnly && t.showStats === "after-vote" ? !0 : t.hasEditButton && this.isEditing ? !1 : this.dataController.hasLocalStats();
|
|
1466
|
+
return t.showStats === void 0 || t.showStats === "never" ? !1 : t.showStats === "always" || t.showStats === "" || t.readOnly && t.showStats === "after-vote" ? !0 : t.hasEditButton && this.isEditing ? !1 : this.dataController.hasLocalStats() || this.dataController.hasInteracted;
|
|
1466
1467
|
}
|
|
1467
1468
|
shouldShowFooter() {
|
|
1468
1469
|
return this.shouldShowSubmitButton() || this.shouldShowStats();
|
|
1469
1470
|
}
|
|
1470
1471
|
shouldShowChart() {
|
|
1471
1472
|
const t = this.host;
|
|
1472
|
-
return t.showChart ? t.readOnly ? this.isChartVisible : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats() || !this.isChartVisible) : !1;
|
|
1473
|
+
return t.showChart ? t.readOnly ? this.isChartVisible : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats() && !this.dataController.hasInteracted || !this.isChartVisible) : !1;
|
|
1473
1474
|
}
|
|
1474
1475
|
shouldShowChartToggle() {
|
|
1475
1476
|
const t = this.host;
|
|
1476
|
-
return t.showChart ? t.readOnly ? !0 : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats()) : !1;
|
|
1477
|
+
return t.showChart ? t.readOnly ? !0 : !(t.hasEditButton && this.isEditing || !this.dataController.hasLocalStats() && !this.dataController.hasInteracted) : !1;
|
|
1477
1478
|
}
|
|
1478
1479
|
shouldShowSubmitButton() {
|
|
1479
1480
|
return !!this.isEditing;
|