mirror of
https://github.com/penpot/penpot.git
synced 2026-08-08 05:48:50 +00:00
🎉 Reset only works after press save
This commit is contained in:
parent
16f470e77d
commit
ea65ae8e42
@ -374,6 +374,7 @@
|
|||||||
conflict (deref conflict*)
|
conflict (deref conflict*)
|
||||||
|
|
||||||
reset-notification* (mf/use-state nil)
|
reset-notification* (mf/use-state nil)
|
||||||
|
reset-pending* (mf/use-state false)
|
||||||
|
|
||||||
clean-editing-state
|
clean-editing-state
|
||||||
(fn []
|
(fn []
|
||||||
@ -381,7 +382,8 @@
|
|||||||
(reset! display-parts* nil)
|
(reset! display-parts* nil)
|
||||||
(reset! recorded-command* nil)
|
(reset! recorded-command* nil)
|
||||||
(reset! conflict* nil)
|
(reset! conflict* nil)
|
||||||
(reset! reset-notification* nil))
|
(reset! reset-notification* nil)
|
||||||
|
(reset! reset-pending* false))
|
||||||
|
|
||||||
effective-section-key (if (= section-key :basics) :workspace section-key)
|
effective-section-key (if (= section-key :basics) :workspace section-key)
|
||||||
|
|
||||||
@ -389,10 +391,12 @@
|
|||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps effective-section-key command-info)
|
(mf/deps effective-section-key command-info)
|
||||||
(fn [shortcut-key]
|
(fn [shortcut-key]
|
||||||
(st/emit! (customize/reset-custom-shortcut shortcut-key (:original-command command-info) effective-section-key))
|
(let [original-cmd (:original-command command-info)]
|
||||||
(reset! reset-notification* (:original-command command-info))
|
(reset! reset-pending* true)
|
||||||
(reset! recorded-command* nil)
|
(reset! recorded-command* original-cmd)
|
||||||
(reset! conflict* nil)))
|
(reset! reset-notification* original-cmd)
|
||||||
|
(reset! conflict* nil)
|
||||||
|
(reset! display-parts* nil))))
|
||||||
|
|
||||||
start-editing
|
start-editing
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
@ -426,11 +430,13 @@
|
|||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(when recorded-command
|
(when recorded-command
|
||||||
(st/emit! (customize/set-custom-shortcut
|
(if (deref reset-pending*)
|
||||||
command
|
(st/emit! (customize/reset-custom-shortcut command recorded-command effective-section-key))
|
||||||
recorded-command
|
(st/emit! (customize/set-custom-shortcut
|
||||||
(:key conflict)
|
command
|
||||||
effective-section-key)))
|
recorded-command
|
||||||
|
(:key conflict)
|
||||||
|
effective-section-key))))
|
||||||
(clean-editing-state)))
|
(clean-editing-state)))
|
||||||
|
|
||||||
on-editable-container-blur
|
on-editable-container-blur
|
||||||
@ -446,12 +452,8 @@
|
|||||||
|
|
||||||
(mf/with-effect [display-parts]
|
(mf/with-effect [display-parts]
|
||||||
(when (some? display-parts)
|
(when (some? display-parts)
|
||||||
(reset! reset-notification* nil)))
|
(reset! reset-notification* nil)
|
||||||
|
(reset! reset-pending* false)))
|
||||||
(mf/with-effect [@reset-notification*]
|
|
||||||
(when-let [_ @reset-notification*]
|
|
||||||
(let [timer (js/setTimeout #(reset! reset-notification* nil) 7000)]
|
|
||||||
(fn [] (js/clearTimeout timer)))))
|
|
||||||
|
|
||||||
(mf/with-effect [is-editing]
|
(mf/with-effect [is-editing]
|
||||||
(when is-editing
|
(when is-editing
|
||||||
@ -524,13 +526,13 @@
|
|||||||
[:span {:class (stl/css :recording-ellipsis)} "..."])])]
|
[:span {:class (stl/css :recording-ellipsis)} "..."])])]
|
||||||
(when-let [default-cmd @reset-notification*]
|
(when-let [default-cmd @reset-notification*]
|
||||||
[:> context-notification* {:level :info :class (stl/css :modal-reset-msg)}
|
[:> context-notification* {:level :info :class (stl/css :modal-reset-msg)}
|
||||||
(tr "shortcuts.edit-modal.reset-to-default")
|
(tr "shortcuts.edit-modal.reset-pending")
|
||||||
[:> shortcuts-keys* {:content default-cmd
|
[:> shortcuts-keys* {:content default-cmd
|
||||||
:command (keyword "default")
|
:command (keyword "default")
|
||||||
:is-customized false
|
:is-customized false
|
||||||
:has-conflict? false}]])
|
:has-conflict? false}]])
|
||||||
|
|
||||||
(when recorded-command
|
(when (and recorded-command (not (deref reset-pending*)))
|
||||||
(if conflict
|
(if conflict
|
||||||
[:> context-notification* {:level :warning :class (stl/css :modal-error-msg)}
|
[:> context-notification* {:level :warning :class (stl/css :modal-error-msg)}
|
||||||
(tr "shortcuts.edit-modal.conflict" (:name conflict))]
|
(tr "shortcuts.edit-modal.conflict" (:name conflict))]
|
||||||
|
|||||||
@ -5707,8 +5707,8 @@ msgid "shortcuts.edit-modal.conflict"
|
|||||||
msgstr "Combination assigned to \"%s\". Saving will remove it there."
|
msgstr "Combination assigned to \"%s\". Saving will remove it there."
|
||||||
|
|
||||||
#: src/app/main/ui/shortcuts.cljs
|
#: src/app/main/ui/shortcuts.cljs
|
||||||
msgid "shortcuts.edit-modal.reset-to-default"
|
msgid "shortcuts.edit-modal.reset-pending"
|
||||||
msgstr "Shortcut reset to default:"
|
msgstr "If you save, this shortcut will return to the original value:"
|
||||||
|
|
||||||
#: src/app/main/ui/shortcuts.cljs
|
#: src/app/main/ui/shortcuts.cljs
|
||||||
msgid "shortcuts.edit-modal.success"
|
msgid "shortcuts.edit-modal.success"
|
||||||
|
|||||||
@ -5562,8 +5562,8 @@ msgid "shortcuts.edit-modal.conflict"
|
|||||||
msgstr "Combinación usada en \"%s\". Guardar este atajo hará que se elimine allí."
|
msgstr "Combinación usada en \"%s\". Guardar este atajo hará que se elimine allí."
|
||||||
|
|
||||||
#: src/app/main/ui/shortcuts.cljs
|
#: src/app/main/ui/shortcuts.cljs
|
||||||
msgid "shortcuts.edit-modal.reset-to-default"
|
msgid "shortcuts.edit-modal.reset-pending"
|
||||||
msgstr "Atajo restablecido a su valor predeterminado:"
|
msgstr "Si guardas, este atajo volvera a su valor original:"
|
||||||
|
|
||||||
#: src/app/main/ui/shortcuts.cljs
|
#: src/app/main/ui/shortcuts.cljs
|
||||||
msgid "shortcuts.edit-modal.success"
|
msgid "shortcuts.edit-modal.success"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user