Skip to content

Commit

Permalink
Fix google cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
eddsaura committed Jun 23, 2023
1 parent 86bce22 commit e5822d8
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 38 deletions.
2 changes: 1 addition & 1 deletion frontend/.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ NEXT_PUBLIC_XMPP_MUC_DOMAIN=muc.meet.jitsi
NEXT_PUBLIC_XMPP_AUTH_DOMAIN=auth.meet.jitsi
NEXT_PUBLIC_JITSI_ROOM_PREFIX=
NEXT_PUBLIC_ENVIRONMENT=dev
NEXT_PUBLIC_TRANSCRIPTIONS_ENABLED=false
NEXT_PUBLIC_TRANSCRIPTIONS_ENABLED=true
17 changes: 11 additions & 6 deletions frontend/src/components/App/ButtonMoreOptions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import { useStooa } from '@/contexts/StooaManager';
import { useModals } from '@/contexts/ModalsContext';
import { useNavigatorType } from '@/hooks/useNavigatorType';
import { supportsCaptureHandle } from '@/lib/helpers';
import Conference from '@/jitsi/Conference';
import { getTranscriptionLanguage } from '@/user/auth';
import { useConference } from '@/jitsi/useConference';
import { useUserAuth } from '@/user/auth/useUserAuth';

interface Props {
unlabeled?: boolean;
Expand Down Expand Up @@ -86,6 +86,11 @@ const ButtonMoreOptions: React.ForwardRefRenderFunction<ButtonHandle, Props> = (
isTranscriberJoined
} = useStooa();

const { stopTranscriptionEvent, startTranscriptionEvent, setConferenceTranscriptionLanguage } =
useConference();

const { getTranscriptionLanguageCookie } = useUserAuth();

const { t } = useTranslation('fishbowl');

const getTranscriptionText = () => {
Expand Down Expand Up @@ -136,19 +141,19 @@ const ButtonMoreOptions: React.ForwardRefRenderFunction<ButtonHandle, Props> = (
};

const handleTranscriptionToggle = () => {
const transcriptionCookie = getTranscriptionLanguage();
const transcriptionCookie = getTranscriptionLanguageCookie();

Check warning on line 144 in frontend/src/components/App/ButtonMoreOptions/index.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/components/App/ButtonMoreOptions/index.tsx#L144

Added line #L144 was not covered by tests

if (!transcriptionCookie) {
setShowTranscriptionModal(true);
return;

Check warning on line 148 in frontend/src/components/App/ButtonMoreOptions/index.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/components/App/ButtonMoreOptions/index.tsx#L147-L148

Added lines #L147 - L148 were not covered by tests
}

if (isTranscriptionEnabled) {
Conference.stopTranscriptionEvent();
stopTranscriptionEvent();
setIsTranscriptionEnabled(false);
} else {
Conference.startTranscriptionEvent();
Conference.setTranscriptionLanguage(transcriptionCookie);
startTranscriptionEvent();
setConferenceTranscriptionLanguage(transcriptionCookie);

Check warning on line 156 in frontend/src/components/App/ButtonMoreOptions/index.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/components/App/ButtonMoreOptions/index.tsx#L152-L156

Added lines #L152 - L156 were not covered by tests
if (deviceType === 'Desktop') {
setParticipantsActive(true);

Check warning on line 158 in frontend/src/components/App/ButtonMoreOptions/index.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/components/App/ButtonMoreOptions/index.tsx#L158

Added line #L158 was not covered by tests
}
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/components/App/Fishbowl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ import useTranslation from 'next-translate/useTranslation';
import RedRec from '@/ui/svg/rec-red.svg';
import FeedbackForm from '../FeedbackForm';
import { useClickOutside } from '@/hooks/useClickOutside';
import TranscriptionText from '../TranscriptionText';
import ModalTranscription from '../ModalTranscription/ModalTranscription';
import { LOCALES } from '@/lib/supportedTranslationLanguages';
import { useConference } from '@/jitsi';
import { useUserAuth } from '@/user/auth/useUserAuth';
import TranscriptionWrapper from '../TranscriptionText/TranscriptionWrapper';

const Header = dynamic(import('../Header'), { loading: () => <div /> });
const Footer = dynamic(import('../Footer'), { loading: () => <div /> });
Expand Down Expand Up @@ -86,8 +86,8 @@ const Fishbowl: FC = () => {
showTranscriptionModal,
setShowTranscriptionModal
} = useModals();
const { startRecordingEvent } = useConference();
const {getTranscriptionLanguage, setTranscriptionLanguage} = useUserAuth();
const { startRecordingEvent, startTranscriptionEvent } = useConference();
const { getTranscriptionLanguageCookie, setTranscriptionLanguageCookie } = useUserAuth();

const { width } = useWindowSize();
const feedbackFormRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -167,13 +167,13 @@ const Fishbowl: FC = () => {
};

const handleStartTranscription = () => {
const transcriptionCookie = getTranscriptionLanguage();
const transcriptionCookie = getTranscriptionLanguageCookie();

if (!transcriptionCookie) {
setTranscriptionLanguage(LOCALES[lang]);
setTranscriptionLanguageCookie(LOCALES[lang]);
}

Conference.startTranscriptionEvent();
startTranscriptionEvent();
setIsTranscriptionEnabled(true);
setParticipantsActive(true);
setShowTranscriptionModal(false);
Expand Down Expand Up @@ -255,7 +255,7 @@ const Fishbowl: FC = () => {

{isPreFishbowl ? <PreFishbowl /> : <Seats />}
<ReactionsReceiver className={participantsActive ? 'drawer-open' : ''} />
{isTranscriptionEnabled && <TranscriptionText />}
{isTranscriptionEnabled && <TranscriptionWrapper />}
</Main>
{!isPreFishbowl && <Footer />}
<OnBoardingTour />
Expand Down
9 changes: 6 additions & 3 deletions frontend/src/components/App/Participants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const PING_TIMEOUT = 3500;

const Participants: React.FC<Props> = ({ initialized, fid }) => {
const { getParticipantList } = useJitsi();
const { ping, setTranscriptionLanguage, getTranscriptionLanguage } = useUserAuth();
const { ping, setTranscriptionLanguageCookie, getTranscriptionLanguageCookie } = useUserAuth();

const { t, lang } = useTranslation('fishbowl');
const pingInterval = useRef<number>();
Expand Down Expand Up @@ -132,7 +132,10 @@ const Participants: React.FC<Props> = ({ initialized, fid }) => {
};

const handleOnChangeTranscription = (event: React.MouseEvent<HTMLInputElement>) => {
const cookieTranscription = getTranscriptionLanguage();
const cookieTranscription = getTranscriptionLanguageCookie();

console.log('PRIMO --->', cookieTranscription);

if (!cookieTranscription) {
event.preventDefault();
setShowTranscriptionModal(true);
Expand All @@ -143,7 +146,7 @@ const Participants: React.FC<Props> = ({ initialized, fid }) => {

if (checkbox && checkbox.checked) {
startTranscriptionEvent();
setTranscriptionLanguage(cookieTranscription);
setTranscriptionLanguageCookie(cookieTranscription);
setIsTranscriptionEnabled(true);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
* file that was distributed with this source code.
*/

import Conference from '@/jitsi/Conference';
import React, { useRef, useState } from 'react';
import LanguageTranscriptionSelector from '../LanguageTranscriptionSelector';
import { StyledTranscriptionWrapper } from './styles';
import InfoSVG from '@/ui/svg/info-brown.svg';
import { getTranscriptionLanguage, setTranscriptionLanguage } from '@/user/auth';
import ColoredFullTooltip from '@/components/Common/ColoredFullTooltip/ColoredFullTooltip';
import useTranslation from 'next-translate/useTranslation';
import { useUserAuth } from '@/user/auth/useUserAuth';
import { useConference } from '@/jitsi/useConference';

interface Props {
tooltip?: boolean;
Expand All @@ -26,12 +26,14 @@ const TranscriptionSelector = ({ tooltip, location }: Props) => {
const [arrowPosition, setArrowPosition] = useState<string>('');
const tipToHover = useRef<HTMLDivElement>(null);
const { t } = useTranslation('fishbowl');
const { getTranscriptionLanguageCookie, setTranscriptionLanguageCookie } = useUserAuth();
const { setConferenceTranscriptionLanguage } = useConference();

const cookieTranscriptionLanguage = getTranscriptionLanguage();
const cookieTranscriptionLanguage = getTranscriptionLanguageCookie();

const handleChangeTranscriptionLanguage = (locale: string): void => {
Conference.setTranscriptionLanguage(locale);
setTranscriptionLanguage(locale);
setConferenceTranscriptionLanguage(locale);
setTranscriptionLanguageCookie(locale);
};

const handleOnMouseEnter: React.MouseEventHandler = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*/

import { useStooa } from '@/contexts/StooaManager';
import Conference from '@/jitsi/Conference';
import LanguageTranscriptionSelector from '../LanguageTranscriptionSelector';
import { StyledSelectorWrapper } from './styles';
import useTranslation from 'next-translate/useTranslation';
import { useConference } from '@/jitsi/useConference';

const TranslateSelector = () => {
const {
Expand All @@ -22,18 +22,20 @@ const TranslateSelector = () => {
setTranslationLanguage
} = useStooa();

const { setConferenceTranslationLanguage } = useConference();

const { t } = useTranslation('fishbowl');

const handleChangedLanguage = (locale: string): void => {
Conference.setTranslationLanguage(locale);
setConferenceTranslationLanguage(locale);
setTranslationLanguage(locale);
};

const handleActiveTranslate = (): void => {
if (!isTranslationEnabled) {
Conference.setTranslationLanguage(translationLanguage);
setConferenceTranslationLanguage(translationLanguage);
} else {
Conference.setTranslationLanguage(null);
setConferenceTranslationLanguage(null);
}
setIsTranslationEnabled(current => !current);
};
Expand Down
11 changes: 8 additions & 3 deletions frontend/src/contexts/StooaManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ const StooaProvider = ({
const { exitFullScreen } = useSharedTrack();
const { initialInteraction, initializeJitsi, initializeConnection, unload, unloadKickedUser } =
useJitsi();
const { setTranscriptionLanguage, stopRecordingEvent, lockConference, joinPrivateConference, joinConference } =
useConference();
const {
setConferenceTranscriptionLanguage,
stopRecordingEvent,
lockConference,
joinPrivateConference,
joinConference
} = useConference();

Check warning on line 81 in frontend/src/contexts/StooaManager.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/contexts/StooaManager.tsx#L81

Added line #L81 was not covered by tests
const { fid } = router.query;
const { t, lang } = useTranslation('app');

Check warning on line 83 in frontend/src/contexts/StooaManager.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/contexts/StooaManager.tsx#L83

Added line #L83 was not covered by tests

Expand Down Expand Up @@ -233,7 +238,7 @@ const StooaProvider = ({
useEventListener(CONFERENCE_START, ({ detail: { myUserId } }) => {
setMyUserId(myUserId);
setConferenceReady(true);
setTranscriptionLanguage(LOCALES[data.locale]);
setConferenceTranscriptionLanguage(LOCALES[data.locale]);

Check warning on line 241 in frontend/src/contexts/StooaManager.tsx

View check run for this annotation

Codecov / codecov/patch

frontend/src/contexts/StooaManager.tsx#L241

Added line #L241 was not covered by tests

if (!isModerator) return;

Expand Down
12 changes: 6 additions & 6 deletions frontend/src/lib/jitsi-modules/useConference.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export const useConference = () => {
conference.on(TRACK_REMOVED, handleTrackRemoved);
conference.on(TRACK_MUTE_CHANGED, handleTrackMuteChanged);
conference.on(USER_JOINED, handleUserJoin);
conference.on(USER_LEFT, handleUserLeft);
conference.on(USER_LEFT, _handleUserLeft);

Check warning on line 280 in frontend/src/lib/jitsi-modules/useConference.js

View check run for this annotation

Codecov / codecov/patch

frontend/src/lib/jitsi-modules/useConference.js#L280

Added line #L280 was not covered by tests
conference.on(KICKED, handleUserKicked);
conference.on(CONFERENCE_JOINED, _handleConferenceJoin);
conference.on(CONFERENCE_FAILED, _handleConferenceFailed);
Expand Down Expand Up @@ -328,7 +328,7 @@ export const useConference = () => {
dispatchEvent(TRANSCRIPTION_TRANSCRIBER_JOINED, { joined: false });

Check warning on line 328 in frontend/src/lib/jitsi-modules/useConference.js

View check run for this annotation

Codecov / codecov/patch

frontend/src/lib/jitsi-modules/useConference.js#L328

Added line #L328 was not covered by tests
}

userRepository.handleUserLeft(id, user);
handleUserLeft(id, user);

Check warning on line 331 in frontend/src/lib/jitsi-modules/useConference.js

View check run for this annotation

Codecov / codecov/patch

frontend/src/lib/jitsi-modules/useConference.js#L331

Added line #L331 was not covered by tests
};

const initializeJitsi = () => {
Expand Down Expand Up @@ -458,11 +458,11 @@ export const useConference = () => {
conference.setLocalParticipantProperty('requestingTranscription', false);

Check warning on line 458 in frontend/src/lib/jitsi-modules/useConference.js

View check run for this annotation

Codecov / codecov/patch

frontend/src/lib/jitsi-modules/useConference.js#L457-L458

Added lines #L457 - L458 were not covered by tests
};

const setTranscriptionLanguage = language => {
const setConferenceTranscriptionLanguage = language => {
conference.setLocalParticipantProperty('transcription_language', language);

Check warning on line 462 in frontend/src/lib/jitsi-modules/useConference.js

View check run for this annotation

Codecov / codecov/patch

frontend/src/lib/jitsi-modules/useConference.js#L462

Added line #L462 was not covered by tests
};

const setTranslationLanguage = language => {
const setConferenceTranslationLanguage = language => {
conference.setLocalParticipantProperty('translation_language', language);

Check warning on line 466 in frontend/src/lib/jitsi-modules/useConference.js

View check run for this annotation

Codecov / codecov/patch

frontend/src/lib/jitsi-modules/useConference.js#L466

Added line #L466 was not covered by tests
};

Expand Down Expand Up @@ -591,8 +591,8 @@ export const useConference = () => {
stopRecordingEvent,
startTranscriptionEvent,
stopTranscriptionEvent,
setTranscriptionLanguage,
setTranslationLanguage,
setConferenceTranscriptionLanguage,
setConferenceTranslationLanguage,
stopTranslation
};
};
5 changes: 4 additions & 1 deletion frontend/src/lib/useJitsi.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export const useJitsi = () => {
isCurrentUser: false,
joined: participant.getProperty('joined') === 'yes',
isMuted: isParticipantMuted(participant, 'audio'),
isVideoMuted: isParticipantMuted(participant, 'video')
isVideoMuted: isParticipantMuted(participant, 'video'),
isJigasi: participant._properties
? participant._properties.features_jigasi !== undefined
: false

Check warning on line 123 in frontend/src/lib/useJitsi.js

View check run for this annotation

Codecov / codecov/patch

frontend/src/lib/useJitsi.js#L122-L123

Added lines #L122 - L123 were not covered by tests
});
});

Expand Down
1 change: 0 additions & 1 deletion frontend/src/user/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ export const setRefreshToken = (value: string) => {
cookie.set(COOKIE_REFRESH, value, { ...COOKIE_OPTIONS, expires: COOKIE_REFRESH_DAYS });
};


export const setToken = (token: string) => {
const auth = new AuthToken(token);
if (auth) {
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/user/auth/useUserAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const COOKIE_SHARE_LINK_COOKIE = 'share_link';
const COOKIE_ON_BOARDING_MODERATOR = 'on_boarding_moderator';
const COOKIE_ON_BOARDING = 'on_boarding';
const COOKIE_ON_BOARDING_DAYS = 30;
const COOKIE_TRANSCRIPTION_LANGUAGE = 'transcription_language';

export const useUserAuth = () => {
const { setUserParticipantId, setUserParticipantSlug, getUserGuestId } = useUser();
Expand Down Expand Up @@ -50,6 +51,17 @@ export const useUserAuth = () => {
return cookie.get(cookieName);
};

const getTranscriptionLanguageCookie = () => {
return cookie.get(COOKIE_TRANSCRIPTION_LANGUAGE);

Check warning on line 55 in frontend/src/user/auth/useUserAuth.ts

View check run for this annotation

Codecov / codecov/patch

frontend/src/user/auth/useUserAuth.ts#L55

Added line #L55 was not covered by tests
};

const setTranscriptionLanguageCookie = (language: string) => {
cookie.set(COOKIE_TRANSCRIPTION_LANGUAGE, language, {

Check warning on line 59 in frontend/src/user/auth/useUserAuth.ts

View check run for this annotation

Codecov / codecov/patch

frontend/src/user/auth/useUserAuth.ts#L59

Added line #L59 was not covered by tests
...COOKIE_OPTIONS,
expires: 30
});
};

const ping = async (lang: string, slug: string) => {
const auth = await getAuthToken();
const params = new FormData();
Expand Down Expand Up @@ -95,6 +107,8 @@ export const useUserAuth = () => {
ping,
setOnBoardingCookie,
setShareLinkCookie,
isFishbowlShareLinkCookie
isFishbowlShareLinkCookie,
getTranscriptionLanguageCookie,
setTranscriptionLanguageCookie
};
};

0 comments on commit e5822d8

Please sign in to comment.