Skip to content

Commit

Permalink
[FIX] Click to join button Jitsi Call (#25569)
Browse files Browse the repository at this point in the history
* fix: Click to join button Jitsi Call

* Fix `yarn` references

* fix: Old message Jitsi Button

* Fix yarn references (again)

* Update apps/meteor/app/action-links/client/lib/actionLinks.ts

Co-authored-by: Tasso Evangelista <[email protected]>

* fix: changing instance type

Co-authored-by: Tasso Evangelista <[email protected]>
  • Loading branch information
hugocostadev and tassoevan authored May 27, 2022
1 parent 78e57f5 commit 5a0d29f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/action-links/client/lib/actionLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const actionLinks = {

// return message;
// },
run(method: string, message: IMessage, instance: undefined): void {
run(method: string, message: IMessage, instance?: Blaze.TemplateInstance | Function): void {
const actionLink = message.actionLinks && message.actionLinks.find((action) => action.method_id === method);

if (!actionLink) {
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/ui-utils/client/lib/messageContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const fields = {
export function messageContext({ rid } = Template.instance()) {
const uid = Meteor.userId();
const user = Users.findOne({ _id: uid }, { fields }) || {};
// const instance = Template.instance();
const instance = Template.instance();
const openThread = (e) => {
const { rid, mid, tmid } = e.currentTarget.dataset;
const room = Rooms.findOne({ _id: rid });
Expand All @@ -55,7 +55,7 @@ export function messageContext({ rid } = Template.instance()) {
value: msg._id,
message: msg,
})
: (msg, actionlink) => actionLinks.run(actionlink, msg);
: (msg, actionlink) => actionLinks.run(actionlink, msg, instance);

const openDiscussion = (e) => {
e.preventDefault();
Expand Down
13 changes: 11 additions & 2 deletions apps/meteor/app/videobridge/client/actionLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ actionLinks.register('joinJitsiCall', function (message, params, instance) {
});

if (jitsiTimeout > clickTime) {
instance.tabBar.open('video');
if (instance instanceof Function) {
instance('video');
} else {
instance.tabBar.open('video');
}

return;
}

Expand All @@ -50,7 +55,11 @@ actionLinks.register('joinJitsiCall', function (message, params, instance) {
}

if (result?.jitsiTimeout && result.jitsiTimeout instanceof Date && result.jitsiTimeout > clickTime) {
instance.tabBar.open('video');
if (instance instanceof Function) {
instance('video');
} else {
instance.tabBar.open('video');
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { IRoom, IMessage, isTranslatedMessage, isMessageReactionsNormalized } from '@rocket.chat/core-typings';
import { useLayout, useUser, useUserPreference, useUserSubscription, useSetting, useEndpoint } from '@rocket.chat/ui-contexts';
import { useLayout, useUser, useUserPreference, useUserSubscription, useSetting, useEndpoint, useUserRoom } from '@rocket.chat/ui-contexts';
import React, { useMemo, FC, memo } from 'react';

import { EmojiPicker } from '../../../../../app/emoji/client';
import { getRegexHighlight, getRegexHighlightUrl } from '../../../../../app/highlight-words/client/helper';
import ToolboxProvider from '../../providers/ToolboxProvider';
import { MessageListContext, MessageListContextValue } from '../contexts/MessageListContext';
import { useAutotranslateLanguage } from '../hooks/useAutotranslateLanguage';

Expand Down Expand Up @@ -132,5 +133,15 @@ export const MessageListProvider: FC<{
],
);

return <MessageListContext.Provider value={context} {...props} />;
const room = useUserRoom(rid);

if (!room) {
throw new Error('Room not found');
}

return (
<ToolboxProvider room={room}>
<MessageListContext.Provider value={context} {...props} />
</ToolboxProvider>
);
});
6 changes: 4 additions & 2 deletions apps/meteor/client/views/room/providers/MessageProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { roomCoordinator } from '../../../lib/rooms/roomCoordinator';
import { fireGlobalEvent } from '../../../lib/utils/fireGlobalEvent';
import { goToRoomById } from '../../../lib/utils/goToRoomById';
import { MessageContext } from '../contexts/MessageContext';
import { useTabBarOpen } from './ToolboxProvider';

export const MessageProvider = memo(function MessageProvider({
rid,
Expand All @@ -20,6 +21,7 @@ export const MessageProvider = memo(function MessageProvider({
broadcast?: boolean;
children: ReactNode;
}) {
const tabBarOpen = useTabBarOpen();
const [routeName, params, queryStringParams] = useCurrentRoute();
const { isEmbedded, isMobile } = useLayout();
const oembedEnabled = Boolean(useSetting('API_Embed'));
Expand Down Expand Up @@ -73,7 +75,7 @@ export const MessageProvider = memo(function MessageProvider({
message: msg,
})
: (msg: IMessage) => (actionLink: string) => (): void => {
actionLinks.run(actionLink, msg, undefined);
actionLinks.run(actionLink, msg, tabBarOpen);
};
return {
oembedEnabled,
Expand Down Expand Up @@ -112,7 +114,7 @@ export const MessageProvider = memo(function MessageProvider({
dateAndTime,
},
};
}, [isEmbedded, oembedEnabled, isMobile, broadcast, time, dateAndTime, router, params, rid, routeName, queryStringParams]);
}, [isEmbedded, oembedEnabled, isMobile, broadcast, time, dateAndTime, router, params, rid, routeName, tabBarOpen, queryStringParams]);

return <MessageContext.Provider value={context}>{children}</MessageContext.Provider>;
});
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8607,7 +8607,7 @@ __metadata:
human-interval: ~1.0.0
moment-timezone: ~0.5.27
mongodb: ~3.5.0
checksum: f5f68008298f9482631f1f494e392cd6b8ba7971a3b0ece81ae2abe60f53d67973ff4476156fa5c9c41b8b58c4ccd284e95c545e0523996dfd05f9a80b843e07
checksum: acb4ebb7e7356f6e53e810d821eb6aa3d88bbfb9e85183e707517bee6d1eea1f189f38bdf0dd2b91360492ab7643134d510c320d2523d86596498ab98e59735b
languageName: node
linkType: hard

Expand Down

0 comments on commit 5a0d29f

Please sign in to comment.