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