remove unused code in presentation service

This commit is contained in:
Ramón Souza 2023-10-09 16:10:02 -03:00
parent 2f9b2d12f8
commit e65740909e
6 changed files with 11 additions and 84 deletions

View File

@ -4,7 +4,6 @@ import { withTracker } from 'meteor/react-meteor-data';
import { injectIntl } from 'react-intl';
import getFromUserSettings from '/imports/ui/services/users-settings';
import Auth from '/imports/ui/services/auth';
import PresentationService from '/imports/ui/components/presentation/service';
import Presentations from '/imports/api/presentations';
import { UsersContext } from '../components-data/users-context/context';
import ActionsBar from './component';
@ -75,7 +74,6 @@ export default withTracker(() => ({
enableVideo: getFromUserSettings('bbb_enable_video', Meteor.settings.public.kurento.enableVideo),
setPresentationIsOpen: MediaService.setPresentationIsOpen,
handleTakePresenter: Service.takePresenterRole,
currentSlidHasContent: PresentationService.currentSlidHasContent(),
isSharingVideo: Service.isSharingVideo(),
isSharedNotesPinned: Service.isSharedNotesPinned(),
hasScreenshare: isScreenBroadcasting(),

View File

@ -953,10 +953,10 @@ class Poll extends Component {
const { isPolling } = this.state;
const {
currentPoll,
currentSlide,
currentSlideId,
} = this.props;
if (!currentSlide) return this.renderNoSlidePanel();
if (!currentSlideId) return this.renderNoSlidePanel();
if (isPolling || currentPoll) {
return this.renderActivePollOptions();
}

View File

@ -1,14 +1,16 @@
import React, { useContext } from 'react';
import { makeCall } from '/imports/ui/services/api';
import { withTracker } from 'meteor/react-meteor-data';
import Presentations from '/imports/api/presentations';
import PresentationService from '/imports/ui/components/presentation/service';
import Poll from '/imports/ui/components/poll/component';
import { Session } from 'meteor/session';
import Service from './service';
import Auth from '/imports/ui/services/auth';
import { UsersContext } from '../components-data/users-context/context';
import { layoutDispatch, layoutSelectInput } from '../layout/context';
import { useSubscription } from '@apollo/client';
import {
CURRENT_PRESENTATION_PAGE_SUBSCRIPTION,
} from '/imports/ui/components/whiteboard/queries';
const CHAT_CONFIG = Meteor.settings.public.chat;
const PUBLIC_CHAT_KEY = CHAT_CONFIG.public_id;
@ -37,15 +39,14 @@ const PollContainer = ({ ...props }) => {
export default withTracker(({ amIPresenter }) => {
const isPollSecret = Session.get('secretPoll') || false;
const currentPresentation = Presentations.findOne({
current: true,
}, { fields: { podId: 1 } }) || {};
Meteor.subscribe('current-poll', isPollSecret, amIPresenter);
const currentSlide = PresentationService.getCurrentSlide(currentPresentation.podId);
const { data: presentationPageData } = useSubscription(CURRENT_PRESENTATION_PAGE_SUBSCRIPTION);
const presentationPage = presentationPageData?.pres_page_curr[0] || {};
const pollId = currentSlide ? currentSlide.id : PUBLIC_CHAT_KEY;
const currentSlideId = presentationPage?.pageId;
const pollId = currentSlideId || PUBLIC_CHAT_KEY;
const { pollTypes } = Service;
@ -57,7 +58,7 @@ export default withTracker(({ amIPresenter }) => {
return {
isPollSecret,
currentSlide,
currentSlideId,
pollTypes,
startPoll,
startCustomPoll,

View File

@ -340,7 +340,6 @@ class PresentationToolbar extends PureComponent {
isMeteorConnected,
isPollingEnabled,
amIPresenter,
currentSlidHasContent,
startPoll,
currentSlide,
slidePosition,
@ -373,7 +372,6 @@ class PresentationToolbar extends PureComponent {
{isPollingEnabled ? (
<Styled.QuickPollButton
{...{
currentSlidHasContent,
intl,
amIPresenter,
startPoll,
@ -540,7 +538,6 @@ PresentationToolbar.propTypes = {
handleToggleFullScreen: PropTypes.func.isRequired,
isPollingEnabled: PropTypes.bool.isRequired,
amIPresenter: PropTypes.bool.isRequired,
currentSlidHasContent: PropTypes.bool.isRequired,
startPoll: PropTypes.func.isRequired,
currentSlide: PropTypes.shape().isRequired,
slidePosition: PropTypes.shape().isRequired,

View File

@ -1,7 +1,6 @@
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { withTracker } from 'meteor/react-meteor-data';
import PresentationService from '/imports/ui/components/presentation/service';
import PollService from '/imports/ui/components/poll/service';
import { makeCall } from '/imports/ui/services/api';
import PresentationToolbar from './component';
@ -71,7 +70,6 @@ export default withTracker((params) => {
skipToSlide: PresentationToolbarService.skipToSlide,
isMeteorConnected: Meteor.status().connected,
isPollingEnabled: isPollingEnabled(),
currentSlidHasContent: PresentationService.currentSlidHasContent(),
startPoll,
};
})(PresentationToolbarContainer);

View File

@ -1,77 +1,10 @@
import Presentations from '/imports/api/presentations';
import { Slides, SlidePositions } from '/imports/api/slides';
const APP = Meteor.settings.public.app;
const getCurrentPresentation = (podId) => Presentations.findOne({
podId,
current: true,
});
const downloadPresentationUri = (podId) => {
const currentPresentation = getCurrentPresentation(podId);
if (!currentPresentation) {
return null;
}
const { originalFileURI: uri } = currentPresentation;
return `${APP.bbbWebBase}/${uri}`;
};
const isPresentationDownloadable = (podId) => {
const currentPresentation = getCurrentPresentation(podId);
if (!currentPresentation) {
return null;
}
return currentPresentation.downloadable;
};
const getCurrentSlide = (podId) => {
const currentPresentation = getCurrentPresentation(podId);
if (!currentPresentation) {
return null;
}
return Slides.findOne({
podId,
presentationId: currentPresentation.id,
current: true,
}, {
fields: {
meetingId: 0,
thumbUri: 0,
txtUri: 0,
},
});
};
const getSlidesLength = (podId) => getCurrentPresentation(podId)?.pages?.length || 0;
const getSlidePosition = (podId, presentationId, slideId) => SlidePositions.findOne({
podId,
presentationId,
id: slideId,
});
const currentSlidHasContent = () => {
const currentSlide = getCurrentSlide('DEFAULT_PRESENTATION_POD');
if (!currentSlide) return false;
const {
content,
} = currentSlide;
return !!content.length;
};
export default {
getCurrentSlide,
getSlidePosition,
isPresentationDownloadable,
downloadPresentationUri,
currentSlidHasContent,
getCurrentPresentation,
getSlidesLength,
};