mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-17 06:09:55 +00:00
[client/ui] Always use async Up in the UI service layer
The UI never needs to block on Up — status updates flow via the SubscribeStatus stream. Hardcode Async:true in Connection.Up and remove the Async field from UpParams so frontend callers are unaffected.
This commit is contained in:
@@ -31,8 +31,9 @@ import * as $models from "./models.js";
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SwitchActive switches to the named profile applying the reconnect policy.
|
* SwitchActive switches to the named profile applying the reconnect policy.
|
||||||
* It returns after the Switch RPC completes so the caller can refresh its UI
|
* All RPCs complete quickly: Up uses async mode so the daemon starts the
|
||||||
* immediately; Down and Up run in a background goroutine.
|
* connection attempt and returns immediately; status updates flow via the
|
||||||
|
* SubscribeStatus stream.
|
||||||
* @param {$models.ProfileRef} p
|
* @param {$models.ProfileRef} p
|
||||||
* @returns {$CancellablePromise<void>}
|
* @returns {$CancellablePromise<void>}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -42,11 +42,6 @@ type WaitSSOParams struct {
|
|||||||
type UpParams struct {
|
type UpParams struct {
|
||||||
ProfileName string `json:"profileName"`
|
ProfileName string `json:"profileName"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
// Async instructs the daemon to start the connection and return
|
|
||||||
// immediately. Status updates flow via the SubscribeStatus stream.
|
|
||||||
// When false (the default) the RPC blocks until connected, which is
|
|
||||||
// the CLI behaviour.
|
|
||||||
Async bool `json:"async"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogoutParams selects the profile the daemon should log out.
|
// LogoutParams selects the profile the daemon should log out.
|
||||||
@@ -152,7 +147,8 @@ func (s *Connection) Up(ctx context.Context, p UpParams) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req := &proto.UpRequest{Async: p.Async}
|
// The UI always uses async mode: status updates flow via SubscribeStatus.
|
||||||
|
req := &proto.UpRequest{Async: true}
|
||||||
if p.ProfileName != "" {
|
if p.ProfileName != "" {
|
||||||
req.ProfileName = ptrStr(p.ProfileName)
|
req.ProfileName = ptrStr(p.ProfileName)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ func (s *ProfileSwitcher) SwitchActive(ctx context.Context, p ProfileRef) error
|
|||||||
if err := s.connection.Up(ctx, UpParams{
|
if err := s.connection.Up(ctx, UpParams{
|
||||||
ProfileName: p.ProfileName,
|
ProfileName: p.ProfileName,
|
||||||
Username: p.Username,
|
Username: p.Username,
|
||||||
Async: true,
|
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return fmt.Errorf("reconnect %q: %w", p.ProfileName, err)
|
return fmt.Errorf("reconnect %q: %w", p.ProfileName, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user