diff --git a/src/UnisonLocal/App.elm b/src/UnisonLocal/App.elm index 0a3188d..503fa9d 100644 --- a/src/UnisonLocal/App.elm +++ b/src/UnisonLocal/App.elm @@ -384,25 +384,12 @@ keydown model keyboardEvent = ( { model | sidebarToggled = not model.sidebarToggled }, Cmd.none ) in case shortcut of - KeyboardShortcut.Chord Ctrl (K _) -> - showFinder model Nothing - - KeyboardShortcut.Chord Meta (K _) -> - if model.env.operatingSystem == Env.MacOS then - showFinder model Nothing - - else - noOp - KeyboardShortcut.Chord Ctrl (B _) -> toggleSidebar KeyboardShortcut.Chord Meta (B _) -> toggleSidebar - KeyboardShortcut.Sequence _ ForwardSlash -> - showFinder model Nothing - KeyboardShortcut.Chord Shift QuestionMark -> ( { model | modal = HelpModal }, Cmd.none ) diff --git a/src/UnisonShare/App.elm b/src/UnisonShare/App.elm index b2d1dc1..682d56f 100644 --- a/src/UnisonShare/App.elm +++ b/src/UnisonShare/App.elm @@ -126,8 +126,8 @@ type Msg update : Msg -> Model -> ( Model, Cmd Msg ) update msg ({ env } as model) = - case msg of - LinkClicked urlRequest -> + case ( model.route, msg ) of + ( _, LinkClicked urlRequest ) -> case urlRequest of Browser.Internal url -> ( model, Nav.pushUrl model.navKey (Url.toString url) ) @@ -137,7 +137,7 @@ update msg ({ env } as model) = Browser.External _ -> ( model, Cmd.none ) - UrlChanged url -> + ( _, UrlChanged url ) -> let route = Route.fromUrl env.basePath url @@ -172,10 +172,10 @@ update msg ({ env } as model) = Route.Perspective params -> fetchPerspectiveAndCodebaseTree env.perspective { model2 | env = newEnv params } - ChangePerspective perspective -> + ( _, ChangePerspective perspective ) -> navigateToPerspective model perspective - FetchPerspectiveNamespaceDetailsFinished fqn details -> + ( _, FetchPerspectiveNamespaceDetailsFinished fqn details ) -> let perspective = case env.perspective of @@ -194,24 +194,24 @@ update msg ({ env } as model) = in ( { model | env = nextEnv }, Cmd.none ) - Keydown event -> + ( _, Keydown event ) -> keydown model event - OpenDefinition ref -> + ( _, OpenDefinition ref ) -> navigateToDefinition model ref - ShowModal modal -> + ( _, ShowModal modal ) -> let ( appModal, cmd ) = AppModal.show modal in ( { model | appModal = appModal }, Cmd.map AppModalMsg cmd ) - ToggleSidebar -> + ( _, ToggleSidebar ) -> ( { model | sidebarToggled = not model.sidebarToggled }, Cmd.none ) -- Sub msgs - AppModalMsg amMsg -> + ( _, AppModalMsg amMsg ) -> let ( am, amCmd, out ) = AppModal.update env amMsg model.appModal @@ -226,27 +226,34 @@ update msg ({ env } as model) = in ( newModel, Cmd.batch [ Cmd.map AppModalMsg amCmd, cmd ] ) - CatalogMsg cMsg -> + ( Route.Catalog, CatalogMsg cMsg ) -> let ( catalog, cmd ) = Catalog.update cMsg model.catalog in ( { model | catalog = catalog }, Cmd.map CatalogMsg cmd ) - WorkspaceMsg wMsg -> - let - ( workspace, wCmd, outMsg ) = - Workspace.update env wMsg model.workspace + ( _, WorkspaceMsg wMsg ) -> + -- TODO: Clean this up, there should be a top level Project route + -- instead of 2 separate workspace routes (perspective and + -- definition) + if model.route /= Route.Catalog then + let + ( workspace, wCmd, outMsg ) = + Workspace.update env wMsg model.workspace - model2 = - { model | workspace = workspace } + model2 = + { model | workspace = workspace } - ( model3, cmd ) = - handleWorkspaceOutMsg model2 outMsg - in - ( model3, Cmd.batch [ cmd, Cmd.map WorkspaceMsg wCmd ] ) + ( model3, cmd ) = + handleWorkspaceOutMsg model2 outMsg + in + ( model3, Cmd.batch [ cmd, Cmd.map WorkspaceMsg wCmd ] ) + + else + ( model, Cmd.none ) - PerspectiveLandingMsg rMsg -> + ( _, PerspectiveLandingMsg rMsg ) -> let ( perspectiveLanding, outMsg ) = PerspectiveLanding.update rMsg model.perspectiveLanding @@ -264,7 +271,7 @@ update msg ({ env } as model) = PerspectiveLanding.None -> ( model2, Cmd.none ) - CodebaseTreeMsg cMsg -> + ( _, CodebaseTreeMsg cMsg ) -> let ( codebaseTree, cCmd, outMsg ) = CodebaseTree.update env cMsg model.codebaseTree @@ -292,13 +299,16 @@ update msg ({ env } as model) = in ( model3, Cmd.batch [ cmd, Cmd.map CodebaseTreeMsg cCmd ] ) - KeyboardShortcutMsg kMsg -> + ( _, KeyboardShortcutMsg kMsg ) -> let ( keyboardShortcut, cmd ) = KeyboardShortcut.update kMsg model.keyboardShortcut in ( { model | keyboardShortcut = keyboardShortcut }, Cmd.map KeyboardShortcutMsg cmd ) + _ -> + ( model, Cmd.none ) + -- UPDATE HELPERS @@ -392,25 +402,12 @@ keydown model keyboardEvent = ( { model | sidebarToggled = not model.sidebarToggled }, Cmd.none ) in case shortcut of - KeyboardShortcut.Chord Ctrl (K _) -> - showFinder model Nothing - - KeyboardShortcut.Chord Meta (K _) -> - if model.env.operatingSystem == Env.MacOS then - showFinder model Nothing - - else - noOp - KeyboardShortcut.Chord Ctrl (B _) -> toggleSidebar KeyboardShortcut.Chord Meta (B _) -> toggleSidebar - KeyboardShortcut.Sequence _ ForwardSlash -> - showFinder model Nothing - KeyboardShortcut.Chord Shift QuestionMark -> let ( am, amCmd ) = diff --git a/src/Workspace.elm b/src/Workspace.elm index c57a156..9b59e66 100644 --- a/src/Workspace.elm +++ b/src/Workspace.elm @@ -175,7 +175,7 @@ update env msg ({ workspaceItems } as model) = KeyboardShortcut.fromKeyboardEvent model.keyboardShortcut event ( nextModel, cmd, out ) = - handleKeyboardShortcut { model | keyboardShortcut = keyboardShortcut } shortcut + handleKeyboardShortcut env { model | keyboardShortcut = keyboardShortcut } shortcut in ( nextModel, Cmd.batch [ cmd, Cmd.map KeyboardShortcutMsg kCmd ], out ) @@ -313,8 +313,8 @@ openDefinitionsFocusToOutMsg openDefs = |> Maybe.withDefault Emptied -handleKeyboardShortcut : Model -> KeyboardShortcut -> ( Model, Cmd Msg, OutMsg ) -handleKeyboardShortcut ({ workspaceItems } as model) shortcut = +handleKeyboardShortcut : Env -> Model -> KeyboardShortcut -> ( Model, Cmd Msg, OutMsg ) +handleKeyboardShortcut env ({ workspaceItems } as model) shortcut = let scrollToCmd = WorkspaceItems.focus @@ -351,6 +351,19 @@ handleKeyboardShortcut ({ workspaceItems } as model) shortcut = ( { model | workspaceItems = next }, scrollToCmd next, openDefinitionsFocusToOutMsg next ) in case shortcut of + KeyboardShortcut.Chord Ctrl (K _) -> + ( model, Cmd.none, ShowFinderRequest Nothing ) + + KeyboardShortcut.Chord Meta (K _) -> + if env.operatingSystem == Env.MacOS then + ( model, Cmd.none, ShowFinderRequest Nothing ) + + else + ( model, Cmd.none, None ) + + Sequence _ ForwardSlash -> + ( model, Cmd.none, ShowFinderRequest Nothing ) + Chord Alt ArrowDown -> moveDown