mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 12:36:11 +02:00
Merge pull request #2409 from penpot/niwinz-hotfix
Fix compatibility issues with safari >=14 & < 16
This commit is contained in:
commit
5ad385cf93
2 changed files with 43 additions and 15 deletions
|
@ -19,24 +19,29 @@
|
|||
|
||||
;; The main broadcast channel instance, used for emit data
|
||||
(defonce default-channel
|
||||
(js/BroadcastChannel. default-topic))
|
||||
(when (exists? js/BroadcastChannel)
|
||||
(js/BroadcastChannel. default-topic)))
|
||||
|
||||
(defonce stream
|
||||
(->> (rx/create (fn [subs]
|
||||
(let [chan (js/BroadcastChannel. default-topic)]
|
||||
(unchecked-set chan "onmessage" #(rx/push! subs (unchecked-get % "data")))
|
||||
(fn [] (.close ^js chan)))))
|
||||
(rx/map t/decode-str)
|
||||
(rx/map map->BroadcastMessage)
|
||||
(rx/share)))
|
||||
(if (exists? js/BroadcastChannel)
|
||||
(->> (rx/create (fn [subs]
|
||||
(let [chan (js/BroadcastChannel. default-topic)]
|
||||
(unchecked-set chan "onmessage" #(rx/push! subs (unchecked-get % "data")))
|
||||
(fn [] (.close ^js chan)))))
|
||||
(rx/map t/decode-str)
|
||||
(rx/map map->BroadcastMessage)
|
||||
(rx/share))
|
||||
(rx/subject)))
|
||||
|
||||
(defn emit!
|
||||
([type data]
|
||||
(.postMessage ^js default-channel (t/encode-str {:id nil :type type :data data}))
|
||||
nil)
|
||||
(when default-channel
|
||||
(.postMessage ^js default-channel (t/encode-str {:id nil :type type :data data}))
|
||||
nil))
|
||||
([id type data]
|
||||
(.postMessage ^js default-channel (t/encode-str {:id id :type type :data data}))
|
||||
nil))
|
||||
(when default-channel
|
||||
(.postMessage ^js default-channel (t/encode-str {:id id :type type :data data}))
|
||||
nil)))
|
||||
|
||||
(defn type?
|
||||
([type]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue