@rangertechnologies/ngnxt 2.1.334 → 2.1.335

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.
@@ -915,28 +915,56 @@ class IndexedDbReaderService {
915
915
  dbName = 'ranger'; //SKS3MAR25 MUST match main app
916
916
  storeName = 'appStore';
917
917
  path = 'translations';
918
- dbVersion = 1;
919
918
  dbPromise;
920
919
  constructor() {
921
920
  this.dbPromise = this.initDB();
922
921
  }
923
922
  initDB() {
924
- return new Promise((resolve, reject) => {
925
- const request = indexedDB.open(this.dbName, this.dbVersion);
926
- request.onsuccess = () => resolve(request.result);
927
- request.onerror = () => reject(request.error);
923
+ return new Promise((resolve) => {
924
+ const request = indexedDB.open(this.dbName);
925
+ request.onsuccess = () => {
926
+ const db = request.result;
927
+ // SKS7MAR26 Skip if store doesn't exist
928
+ if (!db.objectStoreNames.contains(this.storeName)) {
929
+ resolve(null);
930
+ }
931
+ else {
932
+ resolve(db);
933
+ }
934
+ };
935
+ request.onerror = () => resolve(null); // SKS7MAR26 skip DB if error
936
+ request.onupgradeneeded = (event) => {
937
+ // SKS7MAR26 optional: create store only if needed
938
+ const db = event.target.result;
939
+ if (!db.objectStoreNames.contains(this.storeName)) {
940
+ db.createObjectStore(this.storeName);
941
+ }
942
+ };
928
943
  });
929
944
  }
930
945
  async getTranslation(lang) {
931
946
  const db = await this.dbPromise;
932
- return new Promise((resolve, reject) => {
933
- const tx = db.transaction(this.storeName, 'readonly');
934
- const request = tx.objectStore(this.storeName).get(this.path);
935
- request.onsuccess = () => {
936
- const translations = request.result;
937
- resolve(translations ? translations[lang] ?? null : null);
938
- };
939
- request.onerror = () => reject(request.error);
947
+ if (!db) {
948
+ // SKS7MAR26 DB or store not ready → skip gracefully
949
+ return {};
950
+ }
951
+ return this.readTranslation(db, lang);
952
+ }
953
+ readTranslation(db, lang) {
954
+ return new Promise((resolve) => {
955
+ try {
956
+ const tx = db.transaction(this.storeName, 'readonly');
957
+ const request = tx.objectStore(this.storeName).get(this.path);
958
+ request.onsuccess = () => {
959
+ const translations = request.result;
960
+ resolve(translations ? translations[lang] ?? {} : {});
961
+ };
962
+ request.onerror = () => resolve({});
963
+ }
964
+ catch (e) {
965
+ // SKS7MAR26 transaction fails → skip gracefully
966
+ resolve({});
967
+ }
940
968
  });
941
969
  }
942
970
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: IndexedDbReaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
@@ -59020,7 +59048,7 @@ const VERSION = {
59020
59048
  "semver": null,
59021
59049
  "suffix": "68a4eb8b-dirty",
59022
59050
  "semverString": null,
59023
- "version": "2.1.334"
59051
+ "version": "2.1.335"
59024
59052
  };
59025
59053
  /* tslint:enable */
59026
59054