Преглед изворни кода

feat: automatically switch to group of created tab

Jocelyn Boullier пре 4 година
родитељ
комит
8108f97802
2 измењених фајлова са 12 додато и 1 уклоњено
  1. 2 1
      src/Sidebar/Components/Bar.purs
  2. 10 0
      src/Utils.purs

+ 2 - 1
src/Sidebar/Components/Bar.purs

@@ -37,6 +37,7 @@ import PureTabs.Sidebar.Component.GroupName as GroupName
 import PureTabs.Sidebar.Component.TopMenu as TopMenu
 import PureTabs.Sidebar.Tabs (Output(..))
 import PureTabs.Sidebar.Tabs as Tabs
+import PureTabs.Utils (ifU)
 import Sidebar.Utils (moveElem, whenC)
 import Web.HTML.Event.DataTransfer as DT
 import Web.HTML.Event.DragEvent as DE
@@ -405,12 +406,12 @@ handleTabsQuery = case _ of
          state 
          { tabsToGroup = M.insert tab.id tabGroupId s.tabsToGroup 
          , groupTabsPositions = newGroupTabsPositions
+         , currentGroup = tabGroupId
          }
 
        void $ tellChild tabGroupId $ Tabs.TabCreated newTab
        pure $ Just a
 
-
     Tabs.TabDeleted tid reply -> do 
        doOnTabGroup tid \gid -> do 
          H.modify_ (\s -> s 

+ 10 - 0
src/Utils.purs

@@ -0,0 +1,10 @@
+module PureTabs.Utils where
+
+import Control.Alt (void)
+import Control.Bind (pure)
+import Control.Monad (class Monad)
+import Data.Unit (Unit, unit)
+
+
+ifU :: forall a m. Monad m => Boolean -> m a -> m Unit
+ifU bool act = if bool then void act else pure unit