feat(esi): add PostRouteForAllByNames and resolve system names in batch

This commit introduces a new function `PostRouteForAllByNames` to the ESI service, which allows setting a complete route (including waypoints) for all logged-in characters. This is achieved by batch resolving system names to their IDs, improving efficiency and simplifying the process of setting complex routes.

The changes include:
- Adding `ResolveSystemIDsByNames` to `ESISSO` to fetch multiple system IDs in a single ESI request.
- Implementing `PostRouteForAll` in `ESISSO` to handle the logic of setting the destination and waypoints for all characters.
- Updating `App.go` to expose `PostRouteForAllByNames` for frontend use.
- Modifying the frontend component `RegionMap.tsx` to utilize the new `PostRouteForAllByNames` function when setting routes, replacing the previous sequential calls to `SetDestinationForAll` and `AddWaypointForAllByName`.
- Updating Wails generated type definitions (`.d.ts` and `.js`) to reflect the new function.
This commit is contained in:
2025-08-09 20:01:59 +02:00
parent ef57bf4cde
commit f06a60c701
5 changed files with 96 additions and 40 deletions

39
app.go
View File

@@ -58,7 +58,6 @@ func (a *App) StartESILogin() (string, error) {
return url, nil
}
// ESILoginStatus returns a short status string of the active token/character
func (a *App) ESILoginStatus() string {
if a.ssi == nil {
return "not initialised"
@@ -70,7 +69,6 @@ func (a *App) ESILoginStatus() string {
return "not logged in"
}
// ESILoggedIn returns true if a valid access token is present
func (a *App) ESILoggedIn() bool {
if a.ssi == nil {
return false
@@ -78,27 +76,6 @@ func (a *App) ESILoggedIn() bool {
return a.ssi.Status().LoggedIn
}
// SetDestination posts a waypoint to ESI to set destination
func (a *App) SetDestination(destinationID int64, clearOthers bool, addToBeginning bool) error {
if a.ssi == nil {
return errors.New("ESI not initialised")
}
return a.ssi.PostWaypoint(destinationID, clearOthers, addToBeginning)
}
// SetDestinationByName resolves a solar system name to ID and sets destination
func (a *App) SetDestinationByName(systemName string, clearOthers bool, addToBeginning bool) error {
if a.ssi == nil {
return errors.New("ESI not initialised")
}
id, err := a.ssi.ResolveSystemIDByName(a.ctx, systemName)
if err != nil {
return err
}
return a.ssi.PostWaypoint(id, clearOthers, addToBeginning)
}
// SetDestinationForAll resolves system name to ID and applies waypoint to all logged-in characters
func (a *App) SetDestinationForAll(systemName string, clearOthers bool, addToBeginning bool) error {
if a.ssi == nil {
return errors.New("ESI not initialised")
@@ -110,7 +87,6 @@ func (a *App) SetDestinationForAll(systemName string, clearOthers bool, addToBeg
return a.ssi.PostWaypointForAll(id, clearOthers, addToBeginning)
}
// AddWaypointForAllByName resolves system name and appends as waypoint for all characters
func (a *App) AddWaypointForAllByName(systemName string, addToBeginning bool) error {
if a.ssi == nil {
return errors.New("ESI not initialised")
@@ -122,7 +98,20 @@ func (a *App) AddWaypointForAllByName(systemName string, addToBeginning bool) er
return a.ssi.PostWaypointForAll(id, false, addToBeginning)
}
// ListCharacters returns all characters stored in the token DB
// PostRouteForAllByNames posts a full route: via names (in order) then destination at the end (clearing first)
func (a *App) PostRouteForAllByNames(destination string, vias []string) error {
if a.ssi == nil {
return errors.New("ESI not initialised")
}
ids, err := a.ssi.ResolveSystemIDsByNames(a.ctx, append(vias, destination))
if err != nil {
return err
}
viaIDs := ids[:len(vias)]
destID := ids[len(vias)]
return a.ssi.PostRouteForAll(destID, viaIDs)
}
func (a *App) ListCharacters() ([]CharacterInfo, error) {
if a.ssi == nil || a.ssi.db == nil {
return nil, errors.New("ESI not initialised")