diff --git a/frontend/src/app/main/data/dashboard.cljs b/frontend/src/app/main/data/dashboard.cljs index c986116f8..6e34b0f5d 100644 --- a/frontend/src/app/main/data/dashboard.cljs +++ b/frontend/src/app/main/data/dashboard.cljs @@ -834,4 +834,15 @@ action (if in-project? file-created project-created)] (->> (rp/mutation! action-name params) - (rx/map action)))))) \ No newline at end of file + (rx/map action)))))) + +(defn open-selected-file + [] + (ptk/reify ::open-selected-file + ptk/WatchEvent + (watch [_ state _] + (let [files (get-in state [:dashboard-local :selected-files])] + (if (= 1 (count files)) + (let [file (get-in state [:dashboard-files (first files)])] + (rx/of (go-to-workspace file))) + (rx/empty)))))) diff --git a/frontend/src/app/main/ui/dashboard.cljs b/frontend/src/app/main/ui/dashboard.cljs index d27bca6ba..a377a70df 100644 --- a/frontend/src/app/main/ui/dashboard.cljs +++ b/frontend/src/app/main/ui/dashboard.cljs @@ -22,7 +22,10 @@ [app.main.ui.dashboard.sidebar :refer [sidebar]] [app.main.ui.dashboard.team :refer [team-settings-page team-members-page]] [app.main.ui.hooks :as hooks] - [rumext.alpha :as mf])) + [app.util.keyboard :as kbd] + [goog.events :as events] + [rumext.alpha :as mf]) + (:import goog.events.EventType)) (defn ^boolean uuid-str? [s] @@ -95,6 +98,16 @@ (mf/with-effect [team-id] (st/emit! (dd/initialize {:id team-id}))) + (mf/use-effect + (fn [] + (let [events [(events/listen goog/global EventType.KEYDOWN + (fn [event] + (when (kbd/enter? event) + (st/emit! (dd/open-selected-file)))))]] + (fn [] + (doseq [key events] + (events/unlistenByKey key)))))) + [:& (mf/provider ctx/current-team-id) {:value team-id} [:& (mf/provider ctx/current-project-id) {:value project-id} ;; NOTE: dashboard events and other related functions assumes