Skip to content

Commit

Permalink
style: make route related functions return tea.Cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
londek committed Aug 16, 2023
1 parent 78a4a4c commit d5f9f9a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions route.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func WasRouteChanged() bool {
return wasRouteChanged
}

func SetRoute(target string) {
func SetRoute(target string) tea.Cmd {
if !isUpdate {
panic("tried updating global route not in update")
}
Expand All @@ -45,14 +45,15 @@ func SetRoute(target string) {
}

currentRoute = target
return nil
}

func Navigate(target string) {
func Navigate(target string) tea.Cmd {
var currentRouteLevels []string

if len(target) == 0 {
// Just don't navigate if no target was given
return
return nil
}

// Check whether target is absolute
Expand All @@ -75,7 +76,7 @@ func Navigate(target string) {
}
}

SetRoute("/" + strings.Join(currentRouteLevels, "/"))
return SetRoute("/" + strings.Join(currentRouteLevels, "/"))
}

// Checks whether route (e.g. /teams/123/12) matches
Expand Down

0 comments on commit d5f9f9a

Please sign in to comment.