mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-13 09:12:08 -04:00
weather: fix fallback temporarily
This commit is contained in:
@@ -3,12 +3,23 @@ package geolocation
|
||||
import "github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
|
||||
func NewClient() Client {
|
||||
if geoclueClient, err := newGeoClueClient(); err != nil {
|
||||
geoclueClient, err := newGeoClueClient()
|
||||
if err != nil {
|
||||
log.Warnf("Failed to initialize GeoClue2 client: %v", err)
|
||||
} else {
|
||||
log.Info("Falling back to IP location")
|
||||
return newIpClient()
|
||||
}
|
||||
|
||||
loc, _ := geoclueClient.GetLocation()
|
||||
if loc.Latitude != 0 || loc.Longitude != 0 {
|
||||
return geoclueClient
|
||||
}
|
||||
|
||||
log.Info("Falling back to IP location")
|
||||
return newIpClient()
|
||||
log.Info("GeoClue2 has no fix yet, seeding with IP location")
|
||||
ipClient := newIpClient()
|
||||
if ipLoc, err := ipClient.GetLocation(); err == nil {
|
||||
geoclueClient.SeedLocation(ipLoc)
|
||||
}
|
||||
|
||||
return geoclueClient
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user