@fluid-topics/ft-app-context 1.2.46 → 1.2.48

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.
@@ -22,7 +22,7 @@ export declare class FtI18nServiceInternalClass extends FtServiceWithCache {
22
22
  */
23
23
  addContext(context: FtMessageContext): void;
24
24
  getAllContexts(): Array<FtMessageContext>;
25
- prepareContext(name: string, defaultMessages: Record<string, string>): Promise<void>;
25
+ prepareContext(name: string, defaultMessages: Record<string, string>): Promise<FtMessageContext | undefined>;
26
26
  private resolveContext;
27
27
  resolveRawMessage(contextName: string, messageKey: string): any;
28
28
  resolveMessage(contextName: string, message: string, ...args: any[]): string;
@@ -51,7 +51,7 @@ export class FtI18nServiceInternalClass extends FtServiceWithCache {
51
51
  await this.notify(name);
52
52
  }
53
53
  }
54
- await this.fetchContext(name);
54
+ return this.fetchContext(name);
55
55
  }
56
56
  resolveContext(contextName) {
57
57
  var _b, _c;
@@ -70,23 +70,20 @@ export class FtI18nServiceInternalClass extends FtServiceWithCache {
70
70
  return new ParametrizedLabelResolver(((_b = this.defaultMessages[lowerCaseContextName]) !== null && _b !== void 0 ? _b : {}), messages).resolve(message, ...args);
71
71
  }
72
72
  async fetchContext(name) {
73
- var _b, _c, _d;
74
- if (!this.cache.has(name)) {
75
- if (((_c = (_b = window.process) === null || _b === void 0 ? void 0 : _b.env) === null || _c === void 0 ? void 0 : _c.NODE_ENV) === "test") {
76
- this.cache.set(name, (_d = this.defaultMessages[name]) !== null && _d !== void 0 ? _d : {});
77
- }
78
- else {
79
- try {
80
- await this.cache.get(name, () => this.messageContextProvider(this.currentUiLocale, name));
81
- await this.notify(name);
82
- }
83
- catch (e) {
84
- if (!(e instanceof CanceledPromiseError)) {
85
- console.error(e);
86
- }
87
- }
73
+ const isNewContext = !this.cache.has(name);
74
+ let context;
75
+ try {
76
+ context = await this.cache.get(name, () => this.messageContextProvider(this.currentUiLocale, name));
77
+ }
78
+ catch (e) {
79
+ if (!(e instanceof CanceledPromiseError)) {
80
+ console.error(e);
88
81
  }
89
82
  }
83
+ if (isNewContext) {
84
+ await this.notify(name);
85
+ }
86
+ return context;
90
87
  }
91
88
  subscribe(contextName, callback) {
92
89
  var _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-topics/ft-app-context",
3
- "version": "1.2.46",
3
+ "version": "1.2.48",
4
4
  "description": "Global application context for Fluid Topics integrations",
5
5
  "keywords": [
6
6
  "Lit"
@@ -19,11 +19,11 @@
19
19
  "url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
20
20
  },
21
21
  "dependencies": {
22
- "@fluid-topics/ft-wc-utils": "1.2.46",
22
+ "@fluid-topics/ft-wc-utils": "1.2.48",
23
23
  "lit": "3.1.0"
24
24
  },
25
25
  "devDependencies": {
26
- "@fluid-topics/public-api": "1.0.88"
26
+ "@fluid-topics/public-api": "1.0.89"
27
27
  },
28
- "gitHead": "6f4b20e9b729890b8af13cb79dfc6ed07d4389b0"
28
+ "gitHead": "c2298efffb5e12489201c4c46c6b9cd2911adf58"
29
29
  }