@geexcode/geex-angular 0.0.31 → 0.0.33

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/index.js CHANGED
@@ -165,14 +165,21 @@ function createTenantModule(injector) {
165
165
  }
166
166
  function createAuthModule(injector) {
167
167
  const user = (0, import_core.signal)(null);
168
+ let _initPromise = null;
168
169
  const module2 = {
169
- init: async () => {
170
- try {
171
- let userData = await module2.loadUserData();
172
- user.set(userData ?? null);
173
- } catch (err) {
174
- console.error(err);
170
+ init: () => {
171
+ if (_initPromise) {
172
+ return _initPromise;
175
173
  }
174
+ _initPromise = (async () => {
175
+ try {
176
+ const userData = await module2.loadUserData();
177
+ user.set(userData ?? null);
178
+ } catch (err) {
179
+ console.error(err);
180
+ }
181
+ })();
182
+ return _initPromise;
176
183
  },
177
184
  user,
178
185
  async loadUserData() {
@@ -238,10 +245,13 @@ function createMessagingModule(injector) {
238
245
  const module2 = {
239
246
  async init() {
240
247
  try {
241
- const subClient = injector.get(import_apollo_angular.Apollo).use("subscription");
242
- subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe((0, import_rxjs.map)((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
243
- module2.onPublicNotify(notify);
244
- });
248
+ await geex.auth.init();
249
+ if (injector.get(import_angular_oauth2_oidc.OAuthService).hasValidAccessToken()) {
250
+ const subClient = injector.get(import_apollo_angular.Apollo).use("subscription");
251
+ subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe((0, import_rxjs.map)((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
252
+ module2.onPublicNotify(notify);
253
+ });
254
+ }
245
255
  } catch (err) {
246
256
  console.error(err);
247
257
  }
package/dist/index.mjs CHANGED
@@ -119,14 +119,21 @@ function createTenantModule(injector) {
119
119
  }
120
120
  function createAuthModule(injector) {
121
121
  const user = signal(null);
122
+ let _initPromise = null;
122
123
  const module = {
123
- init: async () => {
124
- try {
125
- let userData = await module.loadUserData();
126
- user.set(userData ?? null);
127
- } catch (err) {
128
- console.error(err);
124
+ init: () => {
125
+ if (_initPromise) {
126
+ return _initPromise;
129
127
  }
128
+ _initPromise = (async () => {
129
+ try {
130
+ const userData = await module.loadUserData();
131
+ user.set(userData ?? null);
132
+ } catch (err) {
133
+ console.error(err);
134
+ }
135
+ })();
136
+ return _initPromise;
130
137
  },
131
138
  user,
132
139
  async loadUserData() {
@@ -192,10 +199,13 @@ function createMessagingModule(injector) {
192
199
  const module = {
193
200
  async init() {
194
201
  try {
195
- const subClient = injector.get(Apollo).use("subscription");
196
- subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe(map((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
197
- module.onPublicNotify(notify);
198
- });
202
+ await geex.auth.init();
203
+ if (injector.get(OAuthService).hasValidAccessToken()) {
204
+ const subClient = injector.get(Apollo).use("subscription");
205
+ subClient.subscribe({ query: GQL_ON_PUBLIC_NOTIFY }).pipe(map((res) => res?.data?.onPublicNotify)).subscribe((notify) => {
206
+ module.onPublicNotify(notify);
207
+ });
208
+ }
199
209
  } catch (err) {
200
210
  console.error(err);
201
211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geexcode/geex-angular",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "Angular adapter for Geex core.",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.cjs",