saltfish 0.3.46 → 0.3.47

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.
@@ -9703,7 +9703,6 @@ class TriggerManager {
9703
9703
  * @param playlist - The playlist to evaluate triggers for
9704
9704
  */
9705
9705
  evaluatePlaylistTrigger(playlist) {
9706
- var _a, _b, _c;
9707
9706
  if (!playlist.triggers) {
9708
9707
  return;
9709
9708
  }
@@ -9717,15 +9716,16 @@ class TriggerManager {
9717
9716
  return;
9718
9717
  }
9719
9718
  const conditions = [];
9720
- const maxVisitsCondition = this.evaluateMaxVisitsCondition(triggers.maxVisits, playlistId, ((_a = store.userData) == null ? void 0 : _a.watchedPlaylists) || {});
9719
+ const watchedPlaylists = this.getWatchedPlaylists();
9720
+ const maxVisitsCondition = this.evaluateMaxVisitsCondition(triggers.maxVisits, playlistId, watchedPlaylists);
9721
9721
  conditions.push(maxVisitsCondition);
9722
9722
  const urlCondition = this.evaluateURLCondition(triggers);
9723
9723
  conditions.push(urlCondition);
9724
9724
  log(`TriggerManager: URL condition for playlist ${playlistId}: ${urlCondition} (pattern: ${triggers.url})`);
9725
- const playlistSeenCondition = this.evaluatePlaylistSeenCondition(triggers.playlistSeen, ((_b = store.userData) == null ? void 0 : _b.watchedPlaylists) || {});
9725
+ const playlistSeenCondition = this.evaluatePlaylistSeenCondition(triggers.playlistSeen, watchedPlaylists);
9726
9726
  conditions.push(playlistSeenCondition);
9727
9727
  log(`TriggerManager: PlaylistSeen condition for playlist ${playlistId}: ${playlistSeenCondition} (required: ${JSON.stringify(triggers.playlistSeen)})`);
9728
- const playlistNotSeenCondition = this.evaluatePlaylistNotSeenCondition(triggers.playlistNotSeen, ((_c = store.userData) == null ? void 0 : _c.watchedPlaylists) || {});
9728
+ const playlistNotSeenCondition = this.evaluatePlaylistNotSeenCondition(triggers.playlistNotSeen, watchedPlaylists);
9729
9729
  conditions.push(playlistNotSeenCondition);
9730
9730
  log(`TriggerManager: PlaylistNotSeen condition for playlist ${playlistId}: ${playlistNotSeenCondition} (forbidden: ${JSON.stringify(triggers.playlistNotSeen)})`);
9731
9731
  const elementClickedCondition = this.evaluateElementClickCondition(triggers.elementClicked);
@@ -9743,6 +9743,31 @@ class TriggerManager {
9743
9743
  this.triggerPlaylist(playlistId);
9744
9744
  }
9745
9745
  }
9746
+ /**
9747
+ * Gets watched playlists from backend userData or localStorage (for anonymous users)
9748
+ * @returns WatchedPlaylists object
9749
+ */
9750
+ getWatchedPlaylists() {
9751
+ var _a, _b;
9752
+ const store = getSaltfishStore();
9753
+ if (((_a = store.userData) == null ? void 0 : _a.watchedPlaylists) && Object.keys(store.userData.watchedPlaylists).length > 0) {
9754
+ return store.userData.watchedPlaylists;
9755
+ }
9756
+ const storageManager2 = StorageManager.getInstance();
9757
+ const progressData = storageManager2.getProgress((_b = store.user) == null ? void 0 : _b.id);
9758
+ if (!progressData) {
9759
+ return {};
9760
+ }
9761
+ const watchedPlaylists = {};
9762
+ for (const playlistId of Object.keys(progressData)) {
9763
+ watchedPlaylists[playlistId] = {
9764
+ status: "in_progress",
9765
+ timestamp: Date.now()
9766
+ };
9767
+ }
9768
+ log(`TriggerManager: Built watchedPlaylists from localStorage: ${JSON.stringify(Object.keys(watchedPlaylists))}`);
9769
+ return watchedPlaylists;
9770
+ }
9746
9771
  /**
9747
9772
  * Evaluates the 'maxVisits' condition for a playlist
9748
9773
  * @param maxVisits - Maximum number of times user can see this playlist (null = unlimited)
@@ -12013,7 +12038,7 @@ const SaltfishPlayer$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
12013
12038
  __proto__: null,
12014
12039
  SaltfishPlayer
12015
12040
  }, Symbol.toStringTag, { value: "Module" }));
12016
- const version = "0.3.46";
12041
+ const version = "0.3.47";
12017
12042
  const packageJson = {
12018
12043
  version
12019
12044
  };