Simplify tokenForId

This commit is contained in:
shilangyu 2021-02-24 22:02:36 +01:00
parent e474cebcdb
commit bc7779158c
1 changed files with 3 additions and 6 deletions

View File

@ -139,12 +139,9 @@ class AccountsStore extends ChangeNotifier {
} }
/// returns token for user of a certain id /// returns token for user of a certain id
Jwt tokenForId(String instanceHost, int userId) => Jwt tokenForId(String instanceHost, int userId) => tokens[instanceHost]
tokens.containsKey(instanceHost) ?.values
? tokens[instanceHost] ?.firstWhere((val) => val.payload.id == userId, orElse: () => null);
.values
.firstWhere((val) => val.payload.id == userId, orElse: () => null)
: null;
Jwt tokenFor(String instanceHost, String username) { Jwt tokenFor(String instanceHost, String username) {
if (!usernamesFor(instanceHost).contains(username)) { if (!usernamesFor(instanceHost).contains(username)) {