@pb33f/cowboy-components 0.7.6 → 0.7.8

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.
@@ -237,11 +237,15 @@ export class DiagnosticController extends EventTarget {
237
237
  if (e.instance === 'https://pb33f.io/errors/no-credit-remaining') {
238
238
  this.doc.statusBar.callsRemaining = 0;
239
239
  this.doc.statusBar.visible = true;
240
+ let text = "Run out of credit, please authenticate for more or wait 24 hours.";
241
+ if (this.doc.authController.authenticated) {
242
+ text = "Run out of credit, please purchase more, or come back tomorrow for more free credits.";
243
+ }
240
244
  this.doc.sendToast({
241
245
  id: crypto.randomUUID(),
242
246
  type: ToastType.ERROR,
243
- body: "Run out of credit, please authenticate for more or wait 24 hours.",
244
- title: "Credit exhausted!",
247
+ body: text,
248
+ title: "💰 Credit Exhausted!",
245
249
  });
246
250
  }
247
251
  else {
@@ -1,4 +1,4 @@
1
- import { DocumentationExpirationBag, FunctionDocumentationBag, RuleDocumentationBag } from "../components/the-doctor/the-doctor";
1
+ import { FunctionDocumentationBag, RuleDocumentationBag } from "../components/the-doctor/the-doctor";
2
2
  import { LintingService } from "../services/linting-service";
3
3
  import { ProblemDrawerEventType } from "../components/problem-list/details-drawer";
4
4
  import { ToastType } from "../model/toast";
@@ -8,6 +8,13 @@ export class DocsController extends EventTarget {
8
8
  this.doc = doc;
9
9
  }
10
10
  fetchDocs() {
11
+ const db = this.doc.bagManager.getBag(RuleDocumentationBag);
12
+ const fb = this.doc.bagManager.getBag(FunctionDocumentationBag);
13
+ this.doc.ruleDocsBag = db;
14
+ this.doc.functionDocsBag = fb;
15
+ if ((fb?.export().size ?? 0 > 0) && (db?.export().size ?? 0 > 0)) {
16
+ return;
17
+ }
11
18
  this.doc.activitySpinner.show();
12
19
  const url = new URL(window.location.href);
13
20
  const urlParam = url.searchParams.get('url');
@@ -26,8 +33,6 @@ export class DocsController extends EventTarget {
26
33
  this.doc.platformUnavailable(e);
27
34
  console.error("documentation service is down");
28
35
  });
29
- this.doc.ruleDocsBag = this.doc.bagManager.getBag(RuleDocumentationBag);
30
- this.doc.functionDocsBag = this.doc.bagManager.getBag(FunctionDocumentationBag);
31
36
  // populate docs via worker.
32
37
  this.doc.ruleDocsWorker.addEventListener("message", (event) => {
33
38
  const data = event.data;
@@ -43,14 +48,6 @@ export class DocsController extends EventTarget {
43
48
  this.doc.activitySpinner.hide();
44
49
  }
45
50
  });
46
- // let ruleDocs: string[] = [];
47
- // let functionDocs: string[] = [];
48
- // if (this.ruleDocsBag) {
49
- // ruleDocs = Array.from(this.ruleDocsBag.export().keys());
50
- // }
51
- // if (this.functionDocsBag) {
52
- // functionDocs = Array.from(this.functionDocsBag.export().keys());
53
- // }
54
51
  const fetchDocs = () => {
55
52
  this.doc.ruleDocsWorker.postMessage({
56
53
  start: true,
@@ -59,27 +56,7 @@ export class DocsController extends EventTarget {
59
56
  existingFunctions: []
60
57
  });
61
58
  };
62
- // check expiration
63
- if (this.doc.docExpirationBag) {
64
- const expiration = this.doc.docExpirationBag.get(DocumentationExpirationBag);
65
- // if the docs are older than 15 days, refresh them.
66
- if (expiration) {
67
- const now = new Date().getTime();
68
- const then = new Date(expiration).getTime();
69
- // if (now - then > 1296000000) {
70
- // fetchDocs();
71
- // } else {
72
- // this.activitySpinner.hide();
73
- // }
74
- fetchDocs(); // always fetch for now.
75
- }
76
- else {
77
- fetchDocs();
78
- }
79
- }
80
- else {
81
- fetchDocs();
82
- }
59
+ fetchDocs();
83
60
  }
84
61
  ruleDocsClicked(event) {
85
62
  const ruleId = event.detail.rule;