@smartico/public-api 0.0.298 → 0.0.299

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.
@@ -1894,6 +1894,7 @@ var onUpdateContextKey;
1894
1894
  onUpdateContextKey["Raffles"] = "raffles";
1895
1895
  onUpdateContextKey["JackpotEligibleGames"] = "jackpotEligibleGames";
1896
1896
  onUpdateContextKey["CurrentLevel"] = "currentLevel";
1897
+ onUpdateContextKey["InboxUnreadCount"] = "inboxUnreadCount";
1897
1898
  })(onUpdateContextKey || (onUpdateContextKey = {}));
1898
1899
  /** @group General API */
1899
1900
  class WSAPI {
@@ -1906,7 +1907,6 @@ class WSAPI {
1906
1907
  OCache.clearAll();
1907
1908
  if (this.api.tracker) {
1908
1909
  const on = this.api.tracker.on;
1909
- const triggerExternalCallback = this.api.tracker.triggerExternalCallBack;
1910
1910
  on(ClassId.SAW_SPINS_COUNT_PUSH, data => this.updateOnSpin(data));
1911
1911
  on(ClassId.SAW_SHOW_SPIN_PUSH, () => this.reloadMiniGameTemplate());
1912
1912
  on(ClassId.SAW_AKNOWLEDGE_RESPONSE, () => {
@@ -1941,12 +1941,13 @@ class WSAPI {
1941
1941
  OCache.clear(ECacheContext.WSAPI, onUpdateContextKey.Raffles);
1942
1942
  });
1943
1943
  on(ClassId.GET_INBOX_MESSAGES_RESPONSE, res => {
1944
- var _this$api$tracker;
1945
- const unreadCountInProfile = (_this$api$tracker = this.api.tracker) == null || (_this$api$tracker = _this$api$tracker.userPublicProps) == null ? void 0 : _this$api$tracker.core_inbox_unread_count;
1946
- if (res.unread_count && triggerExternalCallback && unreadCountInProfile !== res.unread_count) {
1947
- triggerExternalCallback('props_change', {
1948
- core_inbox_unread_count: res.unread_count
1949
- });
1944
+ if (res.unread_count !== undefined && res.unread_count !== null) {
1945
+ this.updateInboxUnreadCount(res.unread_count);
1946
+ }
1947
+ });
1948
+ on(ClassId.CLIENT_PUBLIC_PROPERTIES_CHANGED_EVENT, data => {
1949
+ if (data.core_inbox_unread_count !== undefined && data.core_inbox_unread_count !== null) {
1950
+ this.updateInboxUnreadCount(data.core_inbox_unread_count);
1950
1951
  }
1951
1952
  });
1952
1953
  }
@@ -2523,6 +2524,20 @@ class WSAPI {
2523
2524
  }
2524
2525
  return await this.api.getInboxMessagesT(null, from, to, onlyFavorite, categoryId);
2525
2526
  }
2527
+ /**
2528
+ * Returns inbox unread count.
2529
+ *
2530
+ * **Visitor mode: not supported**
2531
+ * @param params
2532
+ */
2533
+ async getInboxUnreadCount({
2534
+ onUpdate
2535
+ } = {}) {
2536
+ if (onUpdate) {
2537
+ this.onUpdateCallback.set(onUpdateContextKey.InboxUnreadCount, onUpdate);
2538
+ }
2539
+ return OCache.use(onUpdateContextKey.InboxUnreadCount, ECacheContext.WSAPI, () => this.api.getInboxUnreadCountT(null), CACHE_DATA_SEC);
2540
+ }
2526
2541
  /**
2527
2542
  * Returns the message body of the specified message guid.
2528
2543
  *
@@ -2630,6 +2645,9 @@ class WSAPI {
2630
2645
  const payload = await this.api.storeGetItemsT(null);
2631
2646
  this.updateEntity(onUpdateContextKey.StoreItems, payload);
2632
2647
  }
2648
+ async updateInboxUnreadCount(count) {
2649
+ this.updateEntity(onUpdateContextKey.InboxUnreadCount, count);
2650
+ }
2633
2651
  async updateInboxMessages() {
2634
2652
  const payload = await this.api.getInboxMessagesT(null);
2635
2653
  this.updateEntity(onUpdateContextKey.InboxMessages, payload);
@@ -3705,6 +3723,11 @@ class SmarticoAPI {
3705
3723
  const offset = from;
3706
3724
  return InboxMessagesTransform((await this.getInboxMessages(user_ext_id, limit, offset, favoriteOnly, categoryId)).log);
3707
3725
  }
3726
+ async getInboxUnreadCountT(user_ext_id) {
3727
+ const limit = 1;
3728
+ const offset = 0;
3729
+ return (await this.getInboxMessages(user_ext_id, limit, offset, false, null)).unread_count;
3730
+ }
3708
3731
  async getInboxMessageBody(messageGuid) {
3709
3732
  var _this3 = this;
3710
3733
  const getMessageBody = async function getMessageBody(messageGuid) {