@kosdev-code/kos-ui-sdk 3.0.23 → 3.0.25

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/index.js CHANGED
@@ -6435,10 +6435,16 @@ let KosTimeModelImpl = class {
6435
6435
  }
6436
6436
  async retrieveTimezone() {
6437
6437
  const tz = await getTimezone();
6438
+ if (!tz) {
6439
+ this.logger.warn(
6440
+ `Failed to retrieve timezone from system. Timezone is undefined.`
6441
+ );
6442
+ return;
6443
+ }
6438
6444
  this.setTimezone(tz);
6439
6445
  }
6440
6446
  setTimezone(tz) {
6441
- this.timezone = tz;
6447
+ this.timezone = tz ?? "";
6442
6448
  }
6443
6449
  /**
6444
6450
  * @internal
@@ -11375,6 +11381,8 @@ let UsbUpdateContainerModelImpl = class {
11375
11381
  updateActiveUpdate(update) {
11376
11382
  this._activeUpdate = update;
11377
11383
  }
11384
+ _isSearching = false;
11385
+ _hasSearched = false;
11378
11386
  // -------------------LIFECYCLE----------------------------
11379
11387
  get isUsbInserted() {
11380
11388
  return this.storageService.isStorageInserted;
@@ -11382,27 +11390,43 @@ let UsbUpdateContainerModelImpl = class {
11382
11390
  get hasAvailableUpdates() {
11383
11391
  return this._models.data.length > 0;
11384
11392
  }
11393
+ get isSearchingUpdates() {
11394
+ return this._isSearching;
11395
+ }
11396
+ get noAvailableUpdates() {
11397
+ return this.isUsbInserted && this._hasSearched && !this._isSearching && this._models.data.length === 0;
11398
+ }
11385
11399
  async syncAvailableUpdates() {
11386
- const updates = await getAvailableUpdates();
11387
11400
  kosAction(() => {
11388
- const allKeys = updates.map(
11389
- (update) => `${update.deviceId}-${update.manifestId}`
11390
- );
11391
- this._models.data.filter((model) => !allKeys.includes(model.id)).forEach((model) => this.removeModel(model.id));
11392
- updates.forEach((update) => {
11393
- const modelId = `${update.deviceId}-${update.manifestId}`;
11394
- const model = UsbUpdate.instance(modelId).forceUpdate.options({
11395
- ...update,
11396
- createTime: new Date(update.createTime)
11397
- }).build();
11398
- this.addModel(model);
11399
- });
11400
- if (this.data.length === 1) {
11401
- this.updateActiveUpdate(this.data[0]);
11402
- } else {
11403
- this.clearActiveUpdate();
11404
- }
11401
+ this._isSearching = true;
11405
11402
  });
11403
+ try {
11404
+ const updates = await getAvailableUpdates();
11405
+ kosAction(() => {
11406
+ const allKeys = updates.map(
11407
+ (update) => `${update.deviceId}-${update.manifestId}`
11408
+ );
11409
+ this._models.data.filter((model) => !allKeys.includes(model.id)).forEach((model) => this.removeModel(model.id));
11410
+ updates.forEach((update) => {
11411
+ const modelId = `${update.deviceId}-${update.manifestId}`;
11412
+ const model = UsbUpdate.instance(modelId).forceUpdate.options({
11413
+ ...update,
11414
+ createTime: new Date(update.createTime)
11415
+ }).build();
11416
+ this.addModel(model);
11417
+ });
11418
+ if (this.data.length === 1) {
11419
+ this.updateActiveUpdate(this.data[0]);
11420
+ } else {
11421
+ this.clearActiveUpdate();
11422
+ }
11423
+ });
11424
+ } finally {
11425
+ kosAction(() => {
11426
+ this._isSearching = false;
11427
+ this._hasSearched = true;
11428
+ });
11429
+ }
11406
11430
  }
11407
11431
  usbInsertedEffect() {
11408
11432
  if (this.isUsbInserted) {
@@ -11410,6 +11434,10 @@ let UsbUpdateContainerModelImpl = class {
11410
11434
  } else {
11411
11435
  this._models.clear();
11412
11436
  this.clearActiveUpdate();
11437
+ kosAction(() => {
11438
+ this._hasSearched = false;
11439
+ this._isSearching = false;
11440
+ });
11413
11441
  }
11414
11442
  }
11415
11443
  async init() {
@@ -11433,7 +11461,12 @@ __decorateClass$9([
11433
11461
  kosChild
11434
11462
  ], UsbUpdateContainerModelImpl.prototype, "_models", 2);
11435
11463
  __decorateClass$9([
11436
- kosModelEffect({ dependencies: (model) => [model.isUsbInserted] })
11464
+ kosModelEffect({
11465
+ dependencies: (model) => [
11466
+ model.isUsbInserted,
11467
+ model.storageService.data.length
11468
+ ]
11469
+ })
11437
11470
  ], UsbUpdateContainerModelImpl.prototype, "usbInsertedEffect", 1);
11438
11471
  UsbUpdateContainerModelImpl = __decorateClass$9([
11439
11472
  kosModel(MODEL_TYPE$8)
@@ -14629,17 +14662,28 @@ const useUsbUpdateContainer = () => {
14629
14662
  const [inserted, setInserted] = useState(false);
14630
14663
  const [updateAvailable, setUpdateAvailable] = useState(false);
14631
14664
  const [updates, setUpdates] = useState([]);
14665
+ const [isSearching, setIsSearching] = useState(false);
14666
+ const [noUpdates, setNoUpdates] = useState(false);
14632
14667
  useEffect(() => {
14633
14668
  const disposer = kosAutoEffect(() => {
14634
14669
  setInserted(result.model?.isUsbInserted ?? false);
14635
14670
  setUpdateAvailable(result.model?.hasAvailableUpdates ?? false);
14636
14671
  setUpdates(result.model?.data ?? []);
14672
+ setIsSearching(result.model?.isSearchingUpdates ?? false);
14673
+ setNoUpdates(result.model?.noAvailableUpdates ?? false);
14637
14674
  });
14638
14675
  return () => {
14639
14676
  disposer();
14640
14677
  };
14641
14678
  }, [result.model]);
14642
- return { ...result, inserted, updateAvailable, updates };
14679
+ return {
14680
+ ...result,
14681
+ inserted,
14682
+ updateAvailable,
14683
+ updates,
14684
+ isSearching,
14685
+ noUpdates
14686
+ };
14643
14687
  };
14644
14688
  function withUsbUpdateContainer(WrappedComponent) {
14645
14689
  return (props) => {