mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-11 08:12:09 -04:00
core/server: initialize geolocation async on startup
This commit is contained in:
@@ -40,7 +40,7 @@ type Manager struct {
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
func NewManager(geoClient geolocation.Client) *Manager {
|
||||
func NewManager() *Manager {
|
||||
m := &Manager{
|
||||
config: Config{
|
||||
Enabled: false,
|
||||
@@ -54,7 +54,6 @@ func NewManager(geoClient geolocation.Client) *Manager {
|
||||
},
|
||||
stopChan: make(chan struct{}),
|
||||
updateTrigger: make(chan struct{}, 1),
|
||||
geoClient: geoClient,
|
||||
}
|
||||
|
||||
m.updateState(time.Now())
|
||||
@@ -315,6 +314,10 @@ func (m *Manager) getConfig() Config {
|
||||
return m.config
|
||||
}
|
||||
|
||||
func (m *Manager) SetGeoClient(client geolocation.Client) {
|
||||
m.geoClient = client
|
||||
}
|
||||
|
||||
func (m *Manager) getLocation(config Config) (*float64, *float64) {
|
||||
if config.Latitude != nil && config.Longitude != nil {
|
||||
return config.Latitude, config.Longitude
|
||||
@@ -322,6 +325,9 @@ func (m *Manager) getLocation(config Config) (*float64, *float64) {
|
||||
if !config.UseIPLocation {
|
||||
return nil, nil
|
||||
}
|
||||
if m.geoClient == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
m.locationMutex.RLock()
|
||||
if m.cachedIPLat != nil && m.cachedIPLon != nil {
|
||||
|
||||
Reference in New Issue
Block a user