pat icon indicating copy to clipboard operation
pat copied to clipboard

Allow Unsorted Connect Aliases

Open DougCollinge opened this issue 4 years ago β€’ 2 comments

Connect aliases are presented sorted into alphanumeric order, which is unnecessary and may be undesired. If the aliases are presented in the order they are entered in config.json then they can be in any order the user desires. This patch allows an unsorted ordering of connect aliases.

The re-ordering comes from storage in a Go map, which has no defined ordering. This patch uses an array for the same purpose, which prevents re-ordering because arrays are inherently ordered.

In order to maintain backward compatibility in the format of config.json an optional new structure is allowed named unsorted_aliases of type [][]string. The first element of the subarray is the alias key and the second element is the URL. If entries are present in unsorted_aliases then they are presented in the aliases dropdown in unsorted order followed by any entries in connect_aliases sorted in alpha order.

DougCollinge avatar Nov 24 '20 02:11 DougCollinge

I think you are on to something hereπŸ‘ Although it would be a more verbose config syntax,an ordered aliases list seems reasonable.

I'm not sure I agree with the proposed data types though. How about defining a new type Alias instead of the inner-most level and make it a []Alias?

type Alias struct {
  Name string `json:"name"`
  URL  string `json:"uri"`
}

Also, with some custom json.Unmarshaller implementiation we can maintain backwards compatibility with the old format without having to introduce a new config parameter πŸ™‚

EDIT: On seconds thoughts, I believe ConnectAlias would be a better name for the new type.

martinhpedersen avatar Jul 10 '21 07:07 martinhpedersen

@DougCollinge - Any chance you're interested in working more on this PR? πŸ™‚

martinhpedersen avatar Feb 23 '22 23:02 martinhpedersen