Skip to content

Commit

Permalink
Merge pull request #1 from GuiLeme/update-0.0.53
Browse files Browse the repository at this point in the history
feat: Update SDK version to 0.0.53 and fix breaking changes
  • Loading branch information
antobinary authored Jul 2, 2024
2 parents dac3b0c + ed15788 commit 7695daa
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 38 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ npm start
url: http://127.0.0.1:4701/static/GenericLinkShare.js
dataChannels:
- name: urlToGenericLink
writePermission: ['moderator','presenter']
deletePermission: ['moderator', 'sender']
pushPermission: ['moderator','presenter']
replaceOrDeletePermission: ['moderator', 'creator']
```
## Building the Plugin
Expand All @@ -49,8 +49,8 @@ public:
url: <<PLUGIN_URL>>
dataChannels:
- name: urlToGenericLink
writePermission: ['moderator','presenter']
deletePermission: ['moderator', 'sender']
pushPermission: ['moderator','presenter']
replaceOrDeletePermission: ['moderator', 'creator']
... // All other configurations
```

Expand Down
14 changes: 7 additions & 7 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
Expand Up @@ -10,7 +10,7 @@
"@types/react": "^18.2.13",
"@types/react-dom": "^18.2.7",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"bigbluebutton-html-plugin-sdk": "0.0.48",
"bigbluebutton-html-plugin-sdk": "0.0.53",
"path": "^0.12.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
54 changes: 28 additions & 26 deletions src/components/generic-link-share/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import {
ActionButtonDropdownOption,
ActionButtonDropdownSeparator,
BbbPluginSdk,
GenericComponent,
GenericContentMainArea,
PluginApi,
LayoutPresentatioAreaUiDataNames,
UiLayouts,
RESET_DATA_CHANNEL,
} from 'bigbluebutton-html-plugin-sdk';

import GenericComponentLinkShare from '../generic-component/component';
Expand All @@ -25,13 +26,13 @@ function GenericLinkShare(
const [showingPresentationContent, setShowingPresentationContent] = useState(false);
const { data: currentUser } = pluginApi.useCurrentUser();
const [link, setLink] = useState<string>(null);
const [data, dispatcher] = pluginApi.useDataChannel<DataToGenericLink>('urlToGenericLink');
const { data: urlToGenericLink, pushEntry: pushEntryUrlToGenericLink, deleteEntry: deleteEntryUrlToGenericLink } = pluginApi.useDataChannel<DataToGenericLink>('urlToGenericLink');
const [linkError, setLinkError] = useState<string>(null);
const [previousModalState, setPreviousModalState] = useState<DataToGenericLink>({
isUrlSameForRole: true,
url: null,
});
const [genericComponentId, setGenericComponentId] = useState<string>('');
const [genericContentd, setGenericContentd] = useState<string>('');

const currentLayout = pluginApi.useUiData(LayoutPresentatioAreaUiDataNames.CURRENT_ELEMENT, [{
isOpen: true,
Expand All @@ -40,8 +41,8 @@ function GenericLinkShare(

useEffect(() => {
const isGenericComponentInPile = currentLayout.some((gc) => (
gc.currentElement === UiLayouts.GENERIC_COMPONENT
&& gc.genericComponentId === genericComponentId
gc.currentElement === UiLayouts.GENERIC_CONTENT
&& gc.genericContentId === genericContentd
));
if (isGenericComponentInPile) {
setShowingPresentationContent(true);
Expand Down Expand Up @@ -97,7 +98,8 @@ function GenericLinkShare(
}
}
if (objectToDispatch) {
dispatcher(objectToDispatch);
deleteEntryUrlToGenericLink([RESET_DATA_CHANNEL]);
pushEntryUrlToGenericLink(objectToDispatch);
setShowModal(false);
} else {
setLinkError('Link is malformed, please insert a valid one');
Expand All @@ -106,37 +108,37 @@ function GenericLinkShare(

useEffect(() => {
if (
data.data
&& data
.data[data.data.length - 1]?.payloadJson
urlToGenericLink.data
&& urlToGenericLink
.data[urlToGenericLink.data.length - 1]?.payloadJson
) {
setPreviousModalState(data
setPreviousModalState(urlToGenericLink
.data[
data.data.length - 1]?.payloadJson);
const isUrlTheSame = data
urlToGenericLink.data.length - 1]?.payloadJson);
const isUrlTheSame = urlToGenericLink
.data[
data.data.length - 1
urlToGenericLink.data.length - 1
]?.payloadJson.isUrlSameForRole;
if (!isUrlTheSame && !currentUser.presenter) {
const viewerUrl = data
const viewerUrl = urlToGenericLink
.data[
data.data.length - 1
urlToGenericLink.data.length - 1
]?.payloadJson.viewerUrl;
if (viewerUrl) {
setLink(viewerUrl);
handleChangePresentationAreaContent(true);
}
} else {
setLink(data
setLink(urlToGenericLink
.data[
data.data.length - 1
urlToGenericLink.data.length - 1
]?.payloadJson.url);
handleChangePresentationAreaContent(true);
}
} else if (
data.data
&& !data
.data[data.data.length - 1]?.payloadJson
urlToGenericLink.data
&& !urlToGenericLink
.data[urlToGenericLink.data.length - 1]?.payloadJson
) {
setLink(null);
setPreviousModalState({
Expand All @@ -145,7 +147,7 @@ function GenericLinkShare(
});
handleChangePresentationAreaContent(false);
}
}, [data, currentUser]);
}, [urlToGenericLink, currentUser]);

useEffect(() => {
if (currentUser?.presenter) {
Expand All @@ -170,7 +172,7 @@ function GenericLinkShare(
: 'Share a generic link into the presentation area',
allowed: true,
onClick: showingPresentationContent ? () => {
dispatcher(null);
deleteEntryUrlToGenericLink([RESET_DATA_CHANNEL]);
setShowingPresentationContent(false);
} : () => {
setShowModal(true);
Expand All @@ -184,9 +186,9 @@ function GenericLinkShare(

useEffect(() => {
if (link && link !== '') {
pluginApi.setGenericComponents([]);
setGenericComponentId(pluginApi.setGenericComponents([
new GenericComponent({
pluginApi.setGenericContentItems([]);
setGenericContentd(pluginApi.setGenericContentItems([
new GenericContentMainArea({
contentFunction: (element: HTMLElement) => {
const root = ReactDOM.createRoot(element);
root.render(
Expand All @@ -200,7 +202,7 @@ function GenericLinkShare(
}),
])[0]);
} else {
pluginApi.setGenericComponents([]);
pluginApi.setGenericContentItems([]);
}
}, [link]);

Expand Down

0 comments on commit 7695daa

Please sign in to comment.