Skip to content

Commit

Permalink
Merge pull request #201 from gjsjohnmurray/ivory-emu
Browse files Browse the repository at this point in the history
Sort our Accounts menu entries when loading them
  • Loading branch information
gjsjohnmurray authored Jul 27, 2023
2 parents b8ee1c7 + 033ca3f commit f94c3da
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/authenticationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export class ServerManagerAuthenticationProvider implements AuthenticationProvid
this._sessions[index] = session;
changed.push(session);
} else {
// No point re-sorting here because onDidChangeSessions always appends added items to the provider's entries in the Accounts menu
this._sessions.push(session);
added.push(session);
}
Expand Down Expand Up @@ -278,7 +279,20 @@ export class ServerManagerAuthenticationProvider implements AuthenticationProvid
const accessToken = await this._secretStorage.get(credentialKey);
return new ServerManagerAuthenticationSession(session.serverName, session.userName, accessToken);
}),
)).filter((session) => session.accessToken);
)).filter((session) => session.accessToken).sort((a, b) => {
const aUserNameLowercase = a.userName.toLowerCase();
const bUserNameLowercase = b.userName.toLowerCase();
if (aUserNameLowercase < bUserNameLowercase) {
return -1;
}
if (aUserNameLowercase > bUserNameLowercase) {
return 1;
}
if (a.serverName < b.serverName) {
return -1;
}
return 1;
});
}

private async _storeStrippedSessions() {
Expand Down

0 comments on commit f94c3da

Please sign in to comment.