Skip to content

Commit

Permalink
fix(optional mutation observer): make mutation observer optional as i…
Browse files Browse the repository at this point in the history
…ts probably not needed all time
  • Loading branch information
rileylnapier committed Jun 14, 2023
1 parent 0df5bb5 commit 216ed74
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/client-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/client-api",
"version": "3.7.0",
"version": "3.7.1",
"description": "",
"main": "dist/index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/client-graphql/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/client-graphql",
"version": "3.7.0",
"version": "3.7.1",
"description": "",
"main": "dist/index.js",
"types": "typings/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions packages/components/__tests__/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ test("will render an inbox and can change labels", async () => {

test("will render nothing and then render an inbox when the element is inserted", async () => {
document.body.innerHTML = "";
act(() => {
(window as any).courierConfig = {
enableMutationObserver: true,
};
});
render(
<CourierProvider
clientKey="MOCK_CLIENT_KEY"
Expand Down
12 changes: 6 additions & 6 deletions packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/components",
"version": "3.7.0",
"version": "3.7.1",
"private": true,
"description": "Beautiful, easy React toast notifications",
"author": "Courier <support@courier.com>",
Expand All @@ -18,11 +18,11 @@
"license": "MIT",
"dependencies": {
"@trycourier/courier": "^1.3.0",
"@trycourier/react-brand-designer": "^3.7.0",
"@trycourier/react-inbox": "^3.7.0",
"@trycourier/react-preferences": "^3.7.0",
"@trycourier/react-provider": "^3.7.0",
"@trycourier/react-toast": "^3.7.0",
"@trycourier/react-brand-designer": "^3.7.1",
"@trycourier/react-inbox": "^3.7.1",
"@trycourier/react-preferences": "^3.7.1",
"@trycourier/react-provider": "^3.7.1",
"@trycourier/react-toast": "^3.7.1",
"babel-loader": "^8.0.6",
"babel-preset-preact": "^2.0.0",
"camel-case": "^4.1.2",
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export const CourierComponents: React.FunctionComponent = () => {
}, [toastConfig, inboxConfig, inboxElement, toastElement]);

useEffect(() => {
if (!window?.courierConfig?.enableMutationObserver) {
return;
}

const observer = new MutationObserver((mutationsList) => {
for (const mutation of mutationsList) {
switch (mutation.type) {
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ declare global {
}
interface ICourierConfig {
apiUrl?: string;
inboxApiUrl?: string;
authorization?: string;
brandId?: string;
clientKey: string;
enableMutationObserver?: boolean;
inboxApiUrl?: string;
onRouteChange?: (route: string) => void;
components?: {
inbox?: any;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-brand-designer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-brand-designer",
"version": "3.7.0",
"version": "3.7.1",
"description": "Embeddable brand designer for multi-channel notifications",
"homepage": "https://github.com/trycourier/courier-react/tree/main/packages/react-elements#readme",
"license": "ISC",
Expand Down Expand Up @@ -29,7 +29,7 @@
"url": "https://github.com/trycourier/courier-react/issues"
},
"dependencies": {
"@trycourier/react-elements": "^3.7.0",
"@trycourier/react-elements": "^3.7.1",
"rimraf": "^3.0.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-elements/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-elements",
"version": "3.7.0",
"version": "3.7.1",
"description": "Shareable components for each Courier package",
"author": "Drew Youngwerth <drew@youngwerth.com>",
"homepage": "https://github.com/trycourier/courier-react/tree/main/packages/react-elements#readme",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-hooks",
"version": "3.7.0",
"version": "3.7.1",
"description": "",
"main": "dist/index.js",
"types": "typings/index.d.ts",
Expand All @@ -20,7 +20,7 @@
"concat-md": "^0.3.5"
},
"dependencies": {
"@trycourier/client-graphql": "^3.7.0",
"@trycourier/client-graphql": "^3.7.1",
"deep-extend": "^0.6.0",
"rimraf": "^3.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-inbox-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-inbox-next",
"version": "3.7.0",
"version": "3.7.1",
"description": "",
"private": true,
"main": "dist/index.js",
Expand Down
10 changes: 5 additions & 5 deletions packages/react-inbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-inbox",
"version": "3.7.0",
"version": "3.7.1",
"description": "",
"main": "dist/index.js",
"types": "typings/index.d.ts",
Expand All @@ -20,10 +20,10 @@
"dependencies": {
"@fontsource/poppins": "^4.5.9",
"@tippyjs/react": "^4.2.3",
"@trycourier/client-graphql": "^3.7.0",
"@trycourier/react-elements": "^3.7.0",
"@trycourier/react-hooks": "^3.7.0",
"@trycourier/react-preferences": "^3.7.0",
"@trycourier/client-graphql": "^3.7.1",
"@trycourier/react-elements": "^3.7.1",
"@trycourier/react-hooks": "^3.7.1",
"@trycourier/react-preferences": "^3.7.1",
"classnames": "^2.2.6",
"date-fns": "^2.19.0",
"deep-extend": "^0.6.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-preferences/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-preferences",
"version": "3.7.0",
"version": "3.7.1",
"main": "dist/index.js",
"types": "typings/index.d.ts",
"scripts": {
Expand All @@ -23,7 +23,7 @@
],
"license": "ISC",
"dependencies": {
"@trycourier/react-hooks": "^3.7.0",
"@trycourier/react-hooks": "^3.7.1",
"react-toggle": "^4.1.2",
"styled-components": "^5.3.6"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-provider",
"version": "3.7.0",
"version": "3.7.1",
"description": "",
"main": "dist/index.js",
"types": "typings/index.d.ts",
Expand All @@ -16,7 +16,7 @@
},
"license": "ISC",
"dependencies": {
"@trycourier/client-graphql": "^3.7.0",
"@trycourier/client-graphql": "^3.7.1",
"buffer": "^6.0.3",
"jwt-decode": "^3.1.2",
"react-use": "^17.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-toast/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/react-toast",
"version": "3.7.0",
"version": "3.7.1",
"description": "Beautiful, easy React toast notifications",
"main": "dist/index.js",
"types": "typings/index.d.ts",
Expand All @@ -24,7 +24,7 @@
"concat-md": "^0.3.5"
},
"dependencies": {
"@trycourier/react-hooks": "^3.7.0",
"@trycourier/react-hooks": "^3.7.1",
"deep-extend": "^0.6.0",
"markdown-to-jsx": "^7.1.7",
"react-toastify": "^9.1.3",
Expand Down
14 changes: 7 additions & 7 deletions packages/storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@trycourier/storybook",
"version": "3.7.0",
"version": "3.7.1",
"private": true,
"description": "Beautiful, easy React toast notifications",
"author": "Courier <support@courier.com>",
Expand All @@ -23,12 +23,12 @@
"@storybook/addon-links": "^6.5.9",
"@storybook/addon-viewport": "^6.5.9",
"@storybook/react": "^6.5.9",
"@trycourier/components": "^3.7.0",
"@trycourier/react-brand-designer": "^3.7.0",
"@trycourier/react-inbox": "^3.7.0",
"@trycourier/react-preferences": "^3.7.0",
"@trycourier/react-provider": "^3.7.0",
"@trycourier/react-toast": "^3.7.0",
"@trycourier/components": "^3.7.1",
"@trycourier/react-brand-designer": "^3.7.1",
"@trycourier/react-inbox": "^3.7.1",
"@trycourier/react-preferences": "^3.7.1",
"@trycourier/react-provider": "^3.7.1",
"@trycourier/react-toast": "^3.7.1",
"react-frame-component": "^5.2.3",
"react-markdown": "^6.0.1",
"storybook": "^6.5.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@trycourier/types",
"private": true,
"version": "3.7.0",
"version": "3.7.1",
"main": "index.d.ts",
"types": "index.d.ts",
"scripts": {}
Expand Down

0 comments on commit 216ed74

Please sign in to comment.