Skip to content

Commit

Permalink
Default supportedEventTypes to empty array (#67)
Browse files Browse the repository at this point in the history
Co-authored-by: BLACKBAUD\Michael.Tims <[email protected]>
  • Loading branch information
michael-tims and michael-tims authored Sep 10, 2024
1 parent 07597ff commit 591db05
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.4.1 (2024-09-10)
- Addressed issue to prevent `supportedEventTypes` to be `undefined`. Should default to empty array.

# 1.4.0 (2024-08-21)
- Added a `actionClick` callback for Box Add-ins to allow developers to take action when actions are clicked.
- Added `AddinBoxConfig` interface for defining configuration options for `Box add-ins`.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blackbaud/sky-addin-client",
"version": "1.4.0",
"version": "1.4.1",
"description": "SKY add-in client",
"main": "dist/bundles/sky-addin-client.umd.js",
"module": "index.ts",
Expand Down
16 changes: 16 additions & 0 deletions src/addin/addin-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,22 @@ describe('AddinClient ', () => {
expect((client as any).supportedEventTypes).toEqual(['update-settings']);
});

it('should initialize add-in with empty event types.',
() => {
const msg: AddinHostMessageEventData = {
message: {
context: 'my_context',
envId: 'my_envid'
},
messageType: 'host-ready',
source: 'bb-addin-host'
};

postMessageFromHost(msg);

expect((client as any).supportedEventTypes).toEqual([]);
});

it('should raise "client-event" event with proper message.',
(done) => {
let postedMessage: any;
Expand Down
6 changes: 3 additions & 3 deletions src/addin/addin-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ export class AddinClient {

this.trackHeightChangesOfAddinContent();

// set the supported event types
this.supportedEventTypes = data.message.supportedEventTypes;
// set the supported event types (default to empty array)
this.supportedEventTypes = data.message.supportedEventTypes || [];

// Pass key data to the add-in for it to initiailze.
this.args.callbacks.init({
Expand All @@ -587,7 +587,7 @@ export class AddinClient {
messageType: 'addin-ready'
});
},
supportedEventTypes : data.message.supportedEventTypes,
supportedEventTypes : this.supportedEventTypes,
themeSettings: data.message.themeSettings
});

Expand Down

0 comments on commit 591db05

Please sign in to comment.