Composer changes for OpenPGP.js

This commit is contained in:
the-djmaze 2022-01-20 09:59:56 +01:00
parent e731343093
commit 3cc3a76b23
3 changed files with 92 additions and 47 deletions

View file

@ -29,7 +29,13 @@ export class OpenPgpKeyModel extends AbstractModel {
this.armor = armor;
this.isPrivate = !!isPrivate;
this.selectUser(userID);
if (this.users) {
const index = this.users.indexOf(userID);
if (-1 !== index) {
this.user = this.users[index];
this.email = this.emails[index];
}
}
this.deleteAccess = ko.observable(false);
}
@ -48,22 +54,4 @@ export class OpenPgpKeyModel extends AbstractModel {
}
return null;
}
select(pattern, property) {
if (this[property]) {
const index = this[property].indexOf(pattern);
if (-1 !== index) {
this.user = this.users[index];
this.email = this.emails[index];
}
}
}
selectUser(user) {
this.select(user, 'users');
}
selectEmail(email) {
this.select(email, 'emails');
}
}