mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 14:56:13 +02:00
Merge pull request #3517 from penpot/niwinz-enhancements-push-notifications
🎉 Add the ability to send push notifications
This commit is contained in:
commit
a1ac839b2a
17 changed files with 388 additions and 74 deletions
|
@ -1157,6 +1157,7 @@ input[type="range"]:focus::-ms-fill-upper {
|
|||
|
||||
.wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.icon {
|
||||
padding: $size-2;
|
||||
|
@ -1173,6 +1174,9 @@ input[type="range"]:focus::-ms-fill-upper {
|
|||
padding: $size-2;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
|
||||
padding: 10px 15px;
|
||||
min-height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
(ns app.main.data.common
|
||||
"A general purpose events."
|
||||
(:require
|
||||
[app.config :as cf]
|
||||
[app.main.data.messages :as msg]
|
||||
[app.main.repo :as rp]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[beicon.core :as rx]
|
||||
[potok.core :as ptk]))
|
||||
|
||||
|
@ -43,3 +46,33 @@
|
|||
(watch [_ _ _]
|
||||
(->> (rp/cmd! :delete-share-link {:id id})
|
||||
(rx/ignore)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; NOTIFICATIONS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn force-reload!
|
||||
[]
|
||||
(.reload js/location))
|
||||
|
||||
(defn handle-notification
|
||||
[{:keys [message code level] :as params}]
|
||||
(ptk/reify ::show-notification
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
(case code
|
||||
:upgrade-version
|
||||
(when (or (not= (:version params) (:full cf/version))
|
||||
(true? (:force params)))
|
||||
(rx/of (msg/dialog
|
||||
:content (tr "notifications.by-code.upgrade-version")
|
||||
:controls :inline-actions
|
||||
:type level
|
||||
:actions [{:label "Refresh" :callback force-reload!}]
|
||||
:tag :notification)))
|
||||
|
||||
(rx/of (msg/dialog
|
||||
:content message
|
||||
:controls :close
|
||||
:type level
|
||||
:tag :notification))))))
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
[app.common.uri :as u]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.data.common :refer [handle-notification]]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.fonts :as df]
|
||||
[app.main.data.media :as di]
|
||||
[app.main.data.users :as du]
|
||||
[app.main.data.websocket :as dws]
|
||||
[app.main.features :as features]
|
||||
[app.main.repo :as rp]
|
||||
[app.util.dom :as dom]
|
||||
|
@ -61,7 +63,23 @@
|
|||
(ptk/watch (fetch-projects) state stream)
|
||||
(ptk/watch (fetch-team-members) state stream)
|
||||
(ptk/watch (du/fetch-teams) state stream)
|
||||
(ptk/watch (du/fetch-users {:team-id id}) state stream)))))
|
||||
(ptk/watch (du/fetch-users {:team-id id}) state stream)
|
||||
|
||||
(let [stoper (rx/filter (ptk/type? ::finalize) stream)
|
||||
profile-id (:profile-id state)]
|
||||
(->> stream
|
||||
(rx/filter (ptk/type? ::dws/message))
|
||||
(rx/map deref)
|
||||
(rx/filter (fn [{:keys [subs-id type] :as msg}]
|
||||
(and (or (= subs-id uuid/zero)
|
||||
(= subs-id profile-id))
|
||||
(= :notification type))))
|
||||
(rx/map handle-notification)
|
||||
(rx/take-until stoper)))))))
|
||||
|
||||
(defn finalize
|
||||
[params]
|
||||
(ptk/data-event ::finalize params))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Data Fetching (context aware: current team)
|
||||
|
|
|
@ -120,6 +120,17 @@
|
|||
:position :fixed
|
||||
:timeout timeout})))
|
||||
|
||||
(defn dialog
|
||||
[& {:keys [content controls actions position tag type]
|
||||
:or {controls :none position :floating type :info}}]
|
||||
(show (d/without-nils
|
||||
{:content content
|
||||
:type type
|
||||
:position position
|
||||
:controls controls
|
||||
:actions actions
|
||||
:tag tag})))
|
||||
|
||||
(defn info-dialog
|
||||
([content controls actions]
|
||||
(info-dialog content controls actions nil))
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
[app.common.data.macros :as dm]
|
||||
[app.common.pages.changes :as cpc]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.common :refer [handle-notification]]
|
||||
[app.main.data.websocket :as dws]
|
||||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.data.workspace.libraries :as dwl]
|
||||
|
@ -57,8 +59,9 @@
|
|||
(rx/filter (ptk/type? ::dws/message))
|
||||
(rx/map deref)
|
||||
(rx/filter (fn [{:keys [subs-id] :as msg}]
|
||||
(or (= subs-id team-id)
|
||||
(or (= subs-id uuid/zero)
|
||||
(= subs-id profile-id)
|
||||
(= subs-id team-id)
|
||||
(= subs-id file-id))))
|
||||
(rx/map process-message))
|
||||
|
||||
|
@ -96,6 +99,7 @@
|
|||
:pointer-update (handle-pointer-update msg)
|
||||
:file-change (handle-file-change msg)
|
||||
:library-change (handle-library-change msg)
|
||||
:notification (handle-notification msg)
|
||||
nil))
|
||||
|
||||
(defn- handle-pointer-send
|
||||
|
|
|
@ -154,18 +154,18 @@
|
|||
(hooks/use-shortcuts ::dashboard sc/shortcuts)
|
||||
|
||||
(mf/with-effect [team-id]
|
||||
(st/emit! (dd/initialize {:id team-id})))
|
||||
(st/emit! (dd/initialize {:id team-id}))
|
||||
(fn []
|
||||
(dd/finalize {:id team-id})))
|
||||
|
||||
(mf/use-effect
|
||||
(fn []
|
||||
(let [events [(events/listen goog/global "keydown"
|
||||
(fn [event]
|
||||
(when (kbd/enter? event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (dd/open-selected-file)))))]]
|
||||
(fn []
|
||||
(doseq [key events]
|
||||
(events/unlistenByKey key))))))
|
||||
(mf/with-effect []
|
||||
(let [key (events/listen goog/global "keydown"
|
||||
(fn [event]
|
||||
(when (kbd/enter? event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (dd/open-selected-file)))))]
|
||||
(fn []
|
||||
(events/unlistenByKey key))))
|
||||
|
||||
[:& (mf/provider ctx/current-team-id) {:value team-id}
|
||||
[:& (mf/provider ctx/current-project-id) {:value project-id}
|
||||
|
|
|
@ -4960,3 +4960,7 @@ msgstr "Marketing"
|
|||
#: src/app/main/ui/onboarding/questions.cljs
|
||||
msgid "questions.student-teacher"
|
||||
msgstr "Student or teacher"
|
||||
|
||||
#: src/app/main/data/common.cljs
|
||||
msgid "notifications.by-code.upgrade-version"
|
||||
msgstr "A new version is available, please refresh the page"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue