Skip to content

Commit

Permalink
Merge pull request #153 from nautls/fix-connection-check
Browse files Browse the repository at this point in the history
Add `ergoConnector.nautilus.isAuthorized()` method
  • Loading branch information
arobsn authored Jun 26, 2024
2 parents 6049a4e + 689f0cd commit 2b67046
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/extension/content-scripts/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ class NautilusAuthApi {
return granted;
}

isConnected() {
isAuthorized() {
return sendMessage(ExternalRequest.CheckConnection, _, CONTENT_SCRIPT);
}

isConnected() {
return Promise.resolve(this.#context !== undefined);
}

async disconnect() {
const disconnected = await sendMessage(ExternalRequest.Disconnect, _, CONTENT_SCRIPT);
if (disconnected) {
Expand All @@ -48,7 +52,9 @@ class NautilusAuthApi {
}

getContext() {
return this.#context ? Promise.resolve(this.#context) : Promise.reject();
return this.#context
? Promise.resolve(this.#context)
: Promise.reject({ code: APIErrorCode.Refused, info: "Not connected." });
}
}

Expand Down

0 comments on commit 2b67046

Please sign in to comment.