Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

paste focus #2134

Merged
merged 4 commits into from
Apr 12, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: don't remove block if there's nothing to paste
filipesilva committed Apr 12, 2022

Verified

This commit was signed with the committer’s verified signature.
TarikGul Tarik Gul
commit e2fd834794780854a76dbbd2d3530d893b387a63
69 changes: 35 additions & 34 deletions src/cljs/athens/events.cljs
Original file line number Diff line number Diff line change
@@ -1628,42 +1628,43 @@
:paste-internal
[(interceptors/sentry-span-no-new-tx "paste-internal")]
(fn [_ [_ uid local-str internal-representation]]
(let [[uid] (db/uid-and-embed-id uid)
op (bfs/build-paste-op @db/dsdb
uid
local-str
internal-representation)
new-titles (graph-ops/ops->new-page-titles op)
new-uids (graph-ops/ops->new-block-uids op)
[_rm add] (graph-ops/structural-diff @db/dsdb op)
event (common-events/build-atomic-event op)
focus-uid (->> op
:op/consequences
(some #(when (= :block/new (:op/type %))
(-> % :op/args :block/uid))))]
(log/debug "paste internal event is" (pr-str event))
{:fx [[:async-flow {:id :paste-internal-async-flow
:db-path [:async-flow :paste-internal]
:first-dispatch [:resolve-transact-forward event]
:rules [{:when :seen?
:events :fail-resolve-forward-transact
:halt? true}
{:when :seen?
:events :success-resolve-forward-transact
:dispatch-n [(when focus-uid
[:editing/uid focus-uid])]
:halt? true}]}]
[:dispatch-n (cond-> []
(when (seq? internal-representation)
(let [[uid] (db/uid-and-embed-id uid)
op (bfs/build-paste-op @db/dsdb
uid
local-str
internal-representation)
new-titles (graph-ops/ops->new-page-titles op)
new-uids (graph-ops/ops->new-block-uids op)
[_rm add] (graph-ops/structural-diff @db/dsdb op)
event (common-events/build-atomic-event op)
focus-uid (->> op
:op/consequences
(some #(when (= :block/new (:op/type %))
(-> % :op/args :block/uid))))]
(log/debug "paste internal event is" (pr-str event))
{:fx [[:async-flow {:id :paste-internal-async-flow
:db-path [:async-flow :paste-internal]
:first-dispatch [:resolve-transact-forward event]
:rules [{:when :seen?
:events :fail-resolve-forward-transact
:halt? true}
{:when :seen?
:events :success-resolve-forward-transact
:dispatch-n [(when focus-uid
[:editing/uid focus-uid])]
:halt? true}]}]
[:dispatch-n (cond-> []

(seq new-titles)
(conj [:reporting/page.create {:source :paste-internal
:count (count new-titles)}])
(seq new-titles)
(conj [:reporting/page.create {:source :paste-internal
:count (count new-titles)}])

(seq new-uids)
(conj [:reporting/block.create {:source :paste-internal
:count (count new-uids)}])
(seq add)
(concat (monitoring/build-reporting-link-creation add :paste-internal)))]]})))
(seq new-uids)
(conj [:reporting/block.create {:source :paste-internal
:count (count new-uids)}])
(seq add)
(concat (monitoring/build-reporting-link-creation add :paste-internal)))]]}))))


(reg-event-fx