mirror of
https://github.com/netbirdio/netbird.git
synced 2026-07-16 11:39:57 +00:00
The wasm client never runs the engine's session-warning flow, so linking the full sessionwatch package (timers, event composition) only bloats the binary. Put the watcher behind a sessionDeadlineWatcher interface and split the constructor by build tag: !js wires the real sessionwatch.Watcher, js gets a no-op stub that still mirrors the deadline into the status recorder (so the Status snapshot stays correct) but drops the timers. Removes the sessionwatch package from the wasm dependency graph.
40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
//go:build js
|
|
|
|
package internal
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/netbirdio/netbird/client/internal/peer"
|
|
)
|
|
|
|
// noopSessionWatcher is the js/wasm stand-in for sessionwatch.Watcher. The
|
|
// wasm client never runs the engine's session-warning flow (the interactive
|
|
// T-WarningLead notification and the T-FinalWarningLead fallback dialog live
|
|
// in the desktop UI), so linking the full sessionwatch package (timers, event
|
|
// composition) would only bloat the binary.
|
|
//
|
|
// It still mirrors the deadline into the status recorder so the SubscribeStatus
|
|
// / Status snapshot the UI consumes stays correct — only the timer-driven
|
|
// warnings are dropped.
|
|
type noopSessionWatcher struct {
|
|
recorder *peer.Status
|
|
}
|
|
|
|
func newSessionWatcher(recorder *peer.Status) sessionDeadlineWatcher {
|
|
return noopSessionWatcher{recorder: recorder}
|
|
}
|
|
|
|
// Update mirrors the real watcher's recorder propagation without the timers or
|
|
// sanity-check sentinels: a valid deadline is exposed on the status snapshot,
|
|
// the zero time clears it.
|
|
func (w noopSessionWatcher) Update(deadline time.Time) error {
|
|
if w.recorder != nil {
|
|
w.recorder.SetSessionExpiresAt(deadline)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (noopSessionWatcher) Dismiss() {}
|
|
func (noopSessionWatcher) Close() {}
|