Repository: penpot/penpot
File: frontend/src/app/main/ui.cljs (ClojureScript)

Code before:
              :or {section :interactions interactions-mode :show-on-click}} query-params
             {:keys [file-id]} path-params]

         [:> viewer-legacy-redirect*
          {:page-id page-id
           :file-id file-id
           :section section
           :index index
           :share-id share-id
           :interactions-mode (keyword interactions-mode)
           :frame-id frame-id
           :share share}])

       :frame-preview
       [:& frame-preview/frame-preview]

       nil)]))

(defn use-prevent-browser-gesture-navigation!
  []
  ;; Prevent the browser from interpreting trackpad horizontal swipe as back/forth
  ;;
  ;; In theory We could disable this only for the workspace. However gets too unreliable.
  ;; It is better to be safe and disable for the dashboard as well.
  (set! (.. js/document -documentElement -style -overscrollBehaviorX) "none")
  (set! (.. js/document -body -style -overscrollBehaviorX) "none"))

(mf/defc app
  []
  (let [route   (mf/deref refs/route)
        edata   (mf/deref refs/exception)
        profile (mf/deref refs/profile)]

    ;; initialize themes
    (theme/use-initialize profile)

    (use-prevent-browser-gesture-navigation!)

    [:& (mf/provider ctx/current-route) {:value route}
     [:& (mf/provider ctx/current-profile) {:value profile}
      (if edata
        [:> static/exception-page* {:data edata :route route}]
        [:> error-boundary* {:fallback static/internal-error*}
         [:> notifications/current-notification*]
         (when route
           [:> page* {:route route :profile profile}])])]]))


Review comment (refactor):
I think we should name it `prevent-browser-gesture-navigation!`  (removing the `use-` prefix because it is not a react hook and right now use- prefix indicates a react hook)

And move it under `app.util.dom` because there we have all the dom manipulation helpers.

Code after:
             {:keys [index share-id section page-id interactions-mode frame-id share]
              :or {section :interactions interactions-mode :show-on-click}} query-params
             {:keys [file-id]} path-params]

         [:> viewer-legacy-redirect*
          {:page-id page-id
           :file-id file-id
           :section section
           :index index
           :share-id share-id
           :interactions-mode (keyword interactions-mode)
           :frame-id frame-id
           :share share}])

       :frame-preview
       [:& frame-preview/frame-preview]

       nil)]))

(mf/defc app
  []
  (let [route   (mf/deref refs/route)
        edata   (mf/deref refs/exception)
        profile (mf/deref refs/profile)]

    ;; initialize themes
    (theme/use-initialize profile)

    (dom/prevent-browser-gesture-navigation!)

    [:& (mf/provider ctx/current-route) {:value route}
     [:& (mf/provider ctx/current-profile) {:value profile}
      (if edata
        [:> static/exception-page* {:data edata :route route}]
        [:> error-boundary* {:fallback static/internal-error*}
         [:> notifications/current-notification*]
         (when route
           [:> page* {:route route :profile profile}])])]]))