ipn/ipnlocal: sort profiles by date created when possible (#20223)
This adds a Created field to LoginProfile to normalize the sort order of login profiles presented in the various client GUIs. The default sort order for existing profiles remains unchanged and continues to be based on Name. Newly added profiles will be stamped at creation time and returned at the top of the list of unstamped profiles, sorted by creation date in descending order. The rationale is to ensure that all clients present the user's profile list in the same order, regardless of newly added accounts, name changes, or nickname overrides. The Mac client was recently updated to remove various custom profile sorting behaviors (https://github.com/tailscale/corp/pull/43847). iOS, Android, and Windows do not currently perform GUI-level sorting, so this change should propagate to them seamlessly. updates tailscale/corp#43843 Signed-off-by: Will Hannah <willh@tailscale.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import (
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"tailscale.com/atomicfile"
|
||||
"tailscale.com/drive"
|
||||
@@ -1091,6 +1092,12 @@ type LoginProfile struct {
|
||||
// ControlURL is the URL of the control server that this profile is logged
|
||||
// into.
|
||||
ControlURL string
|
||||
|
||||
// Created is when this profile was first added to this client. It is
|
||||
// stamped once at profile creation and never changes. It is used to sort
|
||||
// the profile list with newest first; profiles created before this field
|
||||
// existed have a zero value and sort after all stamped profiles.
|
||||
Created time.Time `json:",omitzero"`
|
||||
}
|
||||
|
||||
// Equals reports whether p and p2 are equal.
|
||||
|
||||
Reference in New Issue
Block a user