Skip to content

Commit

Permalink
chore: when app runs without iframe, connect fails
Browse files Browse the repository at this point in the history
Let's allow for connect to finish, even if connections couldn't be established with main thread.
  • Loading branch information
Ruslan Zavacky committed Nov 22, 2023
1 parent 1efd169 commit f468df4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-apples-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crowdstrike/foundry-js': minor
---

Connect message can be undefined, if app runs without iframe. If that happens, we'll gracefully ignore failure and allow application to continue to work.
17 changes: 11 additions & 6 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,20 @@ export default class FalconApi<DATA extends LocalData = LocalData> {
* This establishes a connection to send messages between the extension and the Falcon Console. Only when established you will be able to call other APIs.
*/
public async connect(): Promise<void> {
const { origin, data } = await this.bridge.postMessage({ type: 'connect' });
const response = await this.bridge.postMessage({ type: 'connect' });

this.bridge.setOrigin(origin);
this.data = data;
if (response !== undefined) {
let { origin, data } = response;

this.updateTheme(data?.theme);
this.resizeTracker = new ResizeTracker(this.bridge);
this.bridge.setOrigin(origin);
this.data = data;

this.updateTheme(data?.theme);

this.isConnected = true;
this.isConnected = true;
}

this.resizeTracker = new ResizeTracker(this.bridge);
}

/**
Expand Down

0 comments on commit f468df4

Please sign in to comment.