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
Jwt tokenForId(String instanceHost, int userId) =>
tokens.containsKey(instanceHost)
? tokens[instanceHost]
.values
.firstWhere((val) => val.payload.id == userId, orElse: () => null)
: null;
Jwt tokenForId(String instanceHost, int userId) => tokens[instanceHost]
?.values
?.firstWhere((val) => val.payload.id == userId, orElse: () => null);
Jwt tokenFor(String instanceHost, String username) {
if (!usernamesFor(instanceHost).contains(username)) {