diff --git a/.gitignore b/.gitignore index 89cc6ae..bdee3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ dist node_modules yarn-error.log .DS_Store +.env build cache diff --git a/packages/react-chat-example/package.json b/packages/react-chat-example/package.json index c263dec..dd02099 100644 --- a/packages/react-chat-example/package.json +++ b/packages/react-chat-example/package.json @@ -9,7 +9,7 @@ "clean:all": "yarn clean && rimraf node_modules/", "clean": "rimraf dist/", "build": "rm -rf dist && webpack --mode=production --env ENV=production", - "start": "webpack serve --mode=development --env ENV=development --https", + "start": "webpack serve --mode=development --env ENV=$ENV COMMUNITY_KEY=$COMMUNITY_KEY --https", "fix": "run-s 'fix:*'", "fix:prettier": "prettier './{src,test}/**/*.{ts,tsx}' \"./*.json\" --write", "fix:lint": "eslint './{src,test}/**/*.{ts,tsx}' --fix", diff --git a/packages/react-chat-example/src/index.tsx b/packages/react-chat-example/src/index.tsx index 96885d2..e9a2e04 100644 --- a/packages/react-chat-example/src/index.tsx +++ b/packages/react-chat-example/src/index.tsx @@ -75,9 +75,10 @@ function DragDiv() { diff --git a/packages/react-chat-example/webpack.config.js b/packages/react-chat-example/webpack.config.js index fb7902d..e4a4585 100644 --- a/packages/react-chat-example/webpack.config.js +++ b/packages/react-chat-example/webpack.config.js @@ -5,10 +5,8 @@ const webpack = require('webpack'); const { ESBuildMinifyPlugin } = require('esbuild-loader'); module.exports = env => { - let environment = 'development'; - if (env.ENV) { - environment = env.ENV; - } + const environment = env.ENV || 'development'; + const communityKey = env.COMMUNITY_KEY || ''; return { entry: './src/index.tsx', @@ -71,6 +69,7 @@ module.exports = env => { }), new webpack.DefinePlugin({ 'process.env.ENV': JSON.stringify(environment), + 'process.env.COMMUNITY_KEY': JSON.stringify(communityKey), }), new webpack.ProvidePlugin({ process: 'process/browser.js', diff --git a/packages/react-chat/src/components/ChatLoader.tsx b/packages/react-chat/src/components/ChatLoader.tsx index 54d1f8e..135cdb4 100644 --- a/packages/react-chat/src/components/ChatLoader.tsx +++ b/packages/react-chat/src/components/ChatLoader.tsx @@ -11,17 +11,13 @@ import { import { Chat } from "./Chat"; import { IdentityLoader } from "./Form/IdentityLoader"; -interface ChatLoaderProps { - communityKey: string; -} - -export function ChatLoader({ communityKey }: ChatLoaderProps) { +export function ChatLoader() { const [userCreationState] = useUserCreationState(); if (userCreationState === UserCreationState.NotCreating) return ( - + diff --git a/packages/react-chat/src/components/ReactChat.tsx b/packages/react-chat/src/components/ReactChat.tsx index 5c84a5b..2cac6e0 100644 --- a/packages/react-chat/src/components/ReactChat.tsx +++ b/packages/react-chat/src/components/ReactChat.tsx @@ -2,7 +2,9 @@ import React, { useRef } from "react"; import { ThemeProvider } from "styled-components"; import styled from "styled-components"; +import { ConfigType } from ".."; import { ActivityProvider } from "../contexts/activityProvider"; +import { ConfigProvider } from "../contexts/configProvider"; import { FetchMetadataProvider } from "../contexts/fetchMetadataProvider"; import { ModalProvider } from "../contexts/modalProvider"; import { NarrowProvider } from "../contexts/narrowProvider"; @@ -16,36 +18,34 @@ import { ChatLoader } from "./ChatLoader"; interface ReactChatProps { theme: Theme; - communityKey: string; + config: ConfigType; fetchMetadata?: (url: string) => Promise; } -export function ReactChat({ - theme, - communityKey, - fetchMetadata, -}: ReactChatProps) { +export function ReactChat({ theme, config, fetchMetadata }: ReactChatProps) { const ref = useRef(null); return ( - - - - - - - - - - -