2 Commits

Author SHA1 Message Date
Sharon Kennedy
c8c42e9086 2.2.2 2020-11-12 22:02:26 -05:00
Sharon Kennedy
004f88d5cd pass homeserver query param to get chatbox with settings 2020-11-12 22:01:51 -05:00
6 changed files with 18 additions and 11 deletions

2
dist/bookmarklet.js vendored

File diff suppressed because one or more lines are too long

2
dist/chatbox.js vendored

File diff suppressed because one or more lines are too long

3
dist/index.html vendored
View File

@@ -13,7 +13,8 @@
<script src="./chatbox.js"></script>
<script>
var config = {
settingsEndpoint: 'https://safesupport-admin.herokuapp.com/api/get-settings'
settingsEndpoint: 'https://safesupport-admin.herokuapp.com/api/get-settings',
matrixServerUrl: 'https://matrix.safesupport.chat'
}
EmbeddableChatbox.mount(config);

View File

@@ -1,6 +1,6 @@
{
"name": "private-safesupport-chatbox",
"version": "2.2.1",
"version": "2.2.2",
"description": "A secure and private embeddable chatbox that connects to Riot",
"main": "dist/chatbox.js",
"scripts": {

View File

@@ -13,7 +13,8 @@
<script src="./chatbox.js"></script>
<script>
var config = {
settingsEndpoint: 'https://safesupport-admin.herokuapp.com/api/get-settings'
settingsEndpoint: 'https://safesupport-admin.herokuapp.com/api/get-settings',
matrixServerUrl: 'https://matrix.safesupport.chat'
}
EmbeddableChatbox.mount(config);

View File

@@ -3,22 +3,22 @@ import PropTypes from 'prop-types';
import Chatbox from './chatbox';
const ChatboxWithSettings = ({ settingsEndpoint, ...rest }) => {
const ChatboxWithSettings = ({ settingsEndpoint, matrixServerUrl, ...rest }) => {
const [settings, setSettings] = useState({});
const settingsObj = {};
const getSettings = async () => {
if (!settingsEndpoint) {
const props = {
...rest,
enabled: true
}
enabled: true,
};
return setSettings(props);
}
const res = await fetch(settingsEndpoint);
const url = `${settingsEndpoint}?homeserver=${encodeURIComponent(matrixServerUrl)}`;
const res = await fetch(url);
const data = await res.json();
const { fields } = data;
@@ -42,12 +42,17 @@ const ChatboxWithSettings = ({ settingsEndpoint, ...rest }) => {
}, []);
return (
<Chatbox {...settings} {...rest} />
<Chatbox matrixServerUrl={matrixServerUrl} {...settings} {...rest} />
);
};
ChatboxWithSettings.propTypes = {
matrixServerUrl: PropTypes.string.isRequired,
settingsEndpoint: PropTypes.string,
};
ChatboxWithSettings.defaultProps = {
settingsEndpoint: null,
};
export default ChatboxWithSettings;