Changeset 769 in code for trunk/user.go


Ignore:
Timestamp:
Feb 4, 2022, 2:03:13 PM (3 years ago)
Author:
contact
Message:

Ensure consistent network ordering

Right now there is no consistent ordering in the network list:
no ORDER BY in the DB, and network updates move entries to the end.

Let's always sort by network ID so that users don't see the entries
move around.

I've contemplated sorting by Network.GetName() instead, but:

  • Clients have now way to figure out dynamic order changes, e.g. when renaming a network.
  • Some clients might use ISUPPORT NETWORK when a user hasn't explicitly named a network, but soju won't use that for ordering, leading to non-alphabetic ordering in the client.

Let's leave it to clients to sort the networks by display name if
they want to.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.go

    r768 r769  
    99        "math/big"
    1010        "net"
     11        "sort"
    1112        "time"
    1213
     
    517518        }
    518519
     520        sort.Slice(networks, func(i, j int) bool {
     521                return networks[i].ID < networks[j].ID
     522        })
     523
    519524        for _, record := range networks {
    520525                record := record
     
    766771func (u *user) addNetwork(network *network) {
    767772        u.networks = append(u.networks, network)
     773
     774        sort.Slice(u.networks, func(i, j int) bool {
     775                return u.networks[i].ID < u.networks[j].ID
     776        })
     777
    768778        go network.run()
    769779}
Note: See TracChangeset for help on using the changeset viewer.