Skip to content

Commit 35edcf5

Browse files
authored
Merge pull request #630 from devrnt/555-should-be-able-to-call-boot-more-than-once
555 should be able to call boot more than once
2 parents 7b80ab7 + 8f7ff67 commit 35edcf5

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

.changeset/tall-buses-reply.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-use-intercom': major
3+
---
4+
5+
Allow calling "boot" multiple times. Previously it was not possible to invoke "boot" more than once, because of a "isBooted" guard. This behaviour was not in line with the IntercomJS docs, so it has been removed

packages/react-use-intercom/cypress/e2e/boot.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,31 @@ describe('boot', () => {
5353
cy.get('[data-cy=show]').click();
5454
cy.get('.intercom-lightweight-app-launcher-icon-open').should('not.exist');
5555
});
56+
57+
it('should allow calling `boot` multiple times', () => {
58+
cy.get('[data-cy=boot]').click();
59+
60+
// Wait for the route aliased as 'intercomPing' to respond
61+
// without changing or stubbing its response
62+
cy.wait('@intercomPing');
63+
64+
cy.get('.intercom-lightweight-app-launcher-icon-open').should('exist');
65+
cy.window().should('have.property', 'Intercom');
66+
cy.window().should('have.deep.property', 'intercomSettings', {
67+
app_id: 'jcabc7e3',
68+
});
69+
70+
cy.get('[data-cy="boot-seeded"]').click();
71+
72+
// Wait for the route aliased as 'intercomPing' to respond
73+
// without changing or stubbing its response
74+
cy.wait('@intercomPing');
75+
76+
cy.get('.intercom-lightweight-app-launcher-icon-open').should('exist');
77+
cy.window().should('have.property', 'Intercom');
78+
cy.window().should('have.deep.property', 'intercomSettings', {
79+
app_id: 'jcabc7e3',
80+
name: 'Russo',
81+
});
82+
});
5683
});

packages/react-use-intercom/src/provider.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ export const IntercomProvider: React.FC<
5757
return;
5858
}
5959

60-
if (isBooted.current) {
61-
return;
62-
}
63-
6460
const metaData: RawIntercomBootProps = {
6561
app_id: appId,
6662
...(apiBase && { api_base: apiBase }),

0 commit comments

Comments
 (0)