use graphql to fetch presentation list in actions dropdown

This commit is contained in:
Ramón Souza 2023-10-17 10:20:24 -03:00
parent 1a3d6bbd7b
commit 1575a093d1
3 changed files with 23 additions and 14 deletions

View File

@ -353,10 +353,10 @@ class ActionsDropdown extends PureComponent {
selected: p.current ? true : false,
label: p.name,
description: "uploaded presentation file",
key: `uploaded-presentation-${p.id}`,
key: `uploaded-presentation-${p.presentationId}`,
onClick: () => {
setPresentationFitToWidth(false);
setPresentation(p.id);
setPresentation(p.presentationId);
},
}
);

View File

@ -1,12 +1,14 @@
import React, { useContext } from 'react';
import { withTracker } from 'meteor/react-meteor-data';
import Presentations from '/imports/api/presentations';
import PresentationUploaderService from '/imports/ui/components/presentation/presentation-uploader/service';
import ActionsDropdown from './component';
import { layoutSelectInput, layoutDispatch, layoutSelect } from '../../layout/context';
import { SMALL_VIEWPORT_BREAKPOINT } from '../../layout/enums';
import { isCameraAsContentEnabled, isTimerFeatureEnabled } from '/imports/ui/services/features';
import { PluginsContext } from '/imports/ui/components/components-data/plugin-context/context';
import { useSubscription } from '@apollo/client';
import {
PROCESSED_PRESENTATIONS_SUBSCRIPTION,
} from '/imports/ui/components/whiteboard/queries';
const ActionsDropdownContainer = (props) => {
const sidebarContent = layoutSelectInput((i) => i.sidebarContent);
@ -21,6 +23,9 @@ const ActionsDropdownContainer = (props) => {
actionButtonDropdownItems = [...pluginsProvidedAggregatedState.actionButtonDropdownItems];
}
const { data: presentationData } = useSubscription(PROCESSED_PRESENTATIONS_SUBSCRIPTION);
const presentations = presentationData?.pres_presentation || [];
return (
<ActionsDropdown
{...{
@ -30,19 +35,15 @@ const ActionsDropdownContainer = (props) => {
isMobile,
isRTL,
actionButtonDropdownItems,
presentations,
isTimerFeatureEnabled: isTimerFeatureEnabled(),
isDropdownOpen: Session.get('dropdownOpen'),
setPresentation: PresentationUploaderService.setPresentation,
isCameraAsContentEnabled: isCameraAsContentEnabled(),
...props,
}}
/>
);
};
export default withTracker(() => {
const presentations = Presentations.find({ 'conversion.done': true }).fetch();
return {
presentations,
isTimerFeatureEnabled: isTimerFeatureEnabled(),
isDropdownOpen: Session.get('dropdownOpen'),
setPresentation: PresentationUploaderService.setPresentation,
isCameraAsContentEnabled: isCameraAsContentEnabled(),
};
})(ActionsDropdownContainer);
export default ActionsDropdownContainer;

View File

@ -43,6 +43,14 @@ export const PRESENTATIONS_SUBSCRIPTION = gql`subscription PresentationsSubscrip
}
}`;
export const PROCESSED_PRESENTATIONS_SUBSCRIPTION = gql`subscription ProcessedPresentationsSubscription {
pres_presentation(where: { converting: { _is_null: true }, uploadCompleted: { _eq: true } }) {
current
name
presentationId
}
}`;
export const CURRENT_PAGE_ANNOTATIONS_QUERY = gql`query CurrentPageAnnotationsQuery {
pres_annotation_curr(order_by: { lastUpdatedAt: desc }) {
annotationId