Skip to content

Commit

Permalink
make sure the credential is actually unconfirmed
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Jun 21, 2019
1 parent f4cb489 commit 50fb8e2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
16 changes: 9 additions & 7 deletions src/tinode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4662,13 +4662,15 @@ TopicMe.prototype = Object.create(Topic.prototype, {
});
if (idx < 0) {
// Not found.
// Unconfirmed cerdential replaces previous unconfirmed credential of the same method.
idx = this._credentials.findIndex((el) => {
return el.meth == cr.meth && !el.done;
});
if (idx >= 0) {
// Remove previous unconfirmed credential.
this._credentials.splice(idx, 1);
if (!cr.done) {
// Unconfirmed credential replaces previous unconfirmed credential of the same method.
idx = this._credentials.findIndex((el) => {
return el.meth == cr.meth && !el.done;
});
if (idx >= 0) {
// Remove previous unconfirmed credential.
this._credentials.splice(idx, 1);
}
}
this._credentials.push(cr);
} else {
Expand Down
18 changes: 10 additions & 8 deletions umd/tinode.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion umd/tinode.prod.js

Large diffs are not rendered by default.

0 comments on commit 50fb8e2

Please sign in to comment.