Skip to content

Commit

Permalink
this.shouldFetchUnseenEventsOnConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
bangtoven committed Oct 6, 2023
1 parent 6057932 commit 7ce57a7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/wallet-sdk/src/connection/WalletLinkConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ export class WalletLinkConnection {

case ConnectionState.CONNECTED:
// perform authentication upon connection
// if CONNECTED, authenticate, and then check link status
try {
// if CONNECTED, authenticate, and then check link status
await this.authenticate();

this.sendIsLinked();
this.sendGetSessionConfig();
// check for unseen events
if (this.shouldFetchUnseenEventsOnConnect) {
this.fetchUnseenEventsAPI();
}
connected = true;
} catch {
/* empty */
Expand Down Expand Up @@ -317,8 +320,11 @@ export class WalletLinkConnection {
this.incomingEventListener?.(m);
}

private shouldFetchUnseenEventsOnConnect = false;

public async checkUnseenEvents() {
if (!this.connected) {
this.shouldFetchUnseenEventsOnConnect = true;
return;
}

Expand All @@ -331,6 +337,8 @@ export class WalletLinkConnection {
}

private async fetchUnseenEventsAPI() {
this.shouldFetchUnseenEventsOnConnect = false;

const credentials = `${this.sessionId}:${this.sessionKey}`;
const auth = `Basic ${btoa(credentials)}`;

Expand Down

0 comments on commit 7ce57a7

Please sign in to comment.