Skip to content

Commit 5628238

Browse files
committed
chat: fix bug with video chat button not inserting link and message
1 parent 6e658f1 commit 5628238

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

src/packages/frontend/chat/actions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,15 @@ export class ChatActions extends Actions<ChatState> {
168168
tag,
169169
noNotification,
170170
submitMentionsRef,
171+
extraInput,
171172
}: {
172173
input?: string;
173174
sender_id?: string;
174175
reply_to?: Date;
175176
tag?: string;
176177
noNotification?: boolean;
177178
submitMentionsRef?;
179+
extraInput?: string;
178180
}): string => {
179181
if (this.syncdb == null || this.store == null) {
180182
console.warn("attempt to sendChat before chat actions initialized");
@@ -186,6 +188,9 @@ export class ChatActions extends Actions<ChatState> {
186188
if (submitMentionsRef?.current != null) {
187189
input = submitMentionsRef.current?.({ chat: `${time_stamp.valueOf()}` });
188190
}
191+
if (extraInput) {
192+
input = (input ?? "") + extraInput;
193+
}
189194
input = input?.trim();
190195
if (!input) {
191196
// do not send when there is nothing to send.

src/packages/frontend/chat/chatroom.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,22 @@ export function ChatPanel({
724724
);
725725
}
726726

727-
function sendMessage(replyToOverride?: Date | null): void {
727+
function sendMessage(
728+
replyToOverride?: Date | null,
729+
extraInput?: string,
730+
): void {
728731
const reply_to =
729732
replyToOverride === undefined
730733
? selectedThreadDate
731734
: (replyToOverride ?? undefined);
732735
if (!reply_to) {
733736
setAllowAutoSelectThread(true);
734737
}
735-
const timeStamp = actions.sendChat({ submitMentionsRef, reply_to });
738+
const timeStamp = actions.sendChat({
739+
submitMentionsRef,
740+
reply_to,
741+
extraInput,
742+
});
736743
if (!reply_to && timeStamp) {
737744
setSelectedThreadKey(timeStamp);
738745
setTimeout(() => {
@@ -918,7 +925,14 @@ export function ChatPanel({
918925
<Button
919926
style={{ height: "47.5px" }}
920927
onClick={() => {
921-
actions?.frameTreeActions?.getVideoChat().startChatting();
928+
const message = actions?.frameTreeActions
929+
?.getVideoChat()
930+
.startChatting(actions);
931+
if (!message) {
932+
return;
933+
}
934+
console.log("start video chat returned", { message });
935+
sendMessage(undefined, "\n\n" + message);
922936
}}
923937
>
924938
<Icon name="video-camera" /> Video

src/packages/frontend/chat/video/video-chat.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { webapp_client } from "@cocalc/frontend/webapp-client";
33
import { len, trunc_middle } from "@cocalc/util/misc";
44
import { redux } from "@cocalc/frontend/app-framework";
55
import { open_new_tab } from "../../misc/open-browser-tab";
6-
import { getSideChatActions } from "@cocalc/frontend/frame-editors/generic/chat";
76

87
const VIDEO_CHAT_SERVER = "https://meet.jit.si";
98
const VIDEO_UPDATE_INTERVAL_MS = 30 * 1000;
@@ -83,20 +82,12 @@ export class VideoChat {
8382
this.closeVideoChatWindow();
8483
};
8584

86-
startChatting = () => {
85+
startChatting = (actions) => {
8786
this.openVideoChatWindow();
8887
redux.getActions("file_use")?.mark_file(this.project_id, this.path, "chat");
89-
const sideChatActions =
90-
getSideChatActions({
91-
project_id: this.project_id,
92-
path: this.path,
93-
}) ??
94-
redux.getEditorActions(this.project_id, this.path)?.getChatActions();
95-
sideChatActions?.sendChat({
96-
input: `[${this.getUserName()} joined Video Chat](${this.url()})`,
97-
});
98-
setTimeout(() => sideChatActions?.scrollToBottom(), 100);
99-
setTimeout(() => sideChatActions?.scrollToBottom(), 1000);
88+
setTimeout(() => actions?.scrollToBottom(), 100);
89+
setTimeout(() => actions?.scrollToBottom(), 1000);
90+
return `[${this.getUserName()} joined Video Chat](${this.url()})`
10091
};
10192

10293
// The canonical secret chatroom id.

0 commit comments

Comments
 (0)