Skip to content

Commit 1fcddd8

Browse files
committed
Remove duplicate uid
1 parent 86c50ff commit 1fcddd8

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

frontend/src/components/CodeEditor/index.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@ import { toast } from "react-toastify";
1818

1919
interface CodeEditorProps {
2020
editorState?: { doc: Doc; text: Text; awareness: Awareness };
21-
uid?: string;
22-
username?: string;
2321
language: string;
2422
template?: string;
25-
roomId?: string;
2623
isReadOnly?: boolean;
2724
}
2825

@@ -33,15 +30,7 @@ const languageSupport = {
3330
};
3431

3532
const CodeEditor: React.FC<CodeEditorProps> = (props) => {
36-
const {
37-
editorState,
38-
uid = "",
39-
username = "",
40-
language,
41-
template = "",
42-
roomId = "",
43-
isReadOnly = false,
44-
} = props;
33+
const { editorState, language, template = "", isReadOnly = false } = props;
4534

4635
const collab = useCollab();
4736
if (!collab) {
@@ -51,6 +40,7 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
5140
const {
5241
collabUser,
5342
collabPartner,
43+
roomId,
5444
qnId,
5545
qnTitle,
5646
initDocument,
@@ -74,11 +64,10 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
7464
}
7565

7666
const loadTemplate = async () => {
77-
if (collabUser && collabPartner && qnId && qnTitle) {
67+
if (collabUser && collabPartner && roomId && qnId && qnTitle) {
7868
checkDocReady(roomId, editorState.doc, setIsDocumentLoaded);
7969
try {
8070
await initDocument(
81-
uid,
8271
roomId,
8372
template,
8473
collabUser.id,
@@ -111,13 +100,13 @@ const CodeEditor: React.FC<CodeEditorProps> = (props) => {
111100
indentUnit.of("\t"),
112101
basicSetup(),
113102
languageSupport[language as keyof typeof languageSupport],
114-
...(!isReadOnly && editorState
103+
...(!isReadOnly && editorState && roomId && collabUser
115104
? [
116105
yCollab(editorState.text, editorState.awareness),
117106
cursorExtension(
118107
roomId,
119-
uid,
120-
username,
108+
collabUser.id,
109+
collabUser.username,
121110
sendCursorUpdate,
122111
receiveCursorUpdate
123112
),

frontend/src/contexts/CollabContext.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ type CollabContextType = {
6868
join: (uid: string, roomId: string) => Promise<CollabSessionData>;
6969
leave: (uid: string, roomId: string, isPartnerNotified: boolean) => void;
7070
initDocument: (
71-
uid: string,
7271
roomId: string,
7372
template: string,
7473
uid1: string,
@@ -251,7 +250,6 @@ const CollabProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
251250
};
252251

253252
const initDocument = (
254-
uid: string,
255253
roomId: string,
256254
template: string,
257255
uid1: string,
@@ -277,7 +275,7 @@ const CollabProvider: React.FC<{ children?: React.ReactNode }> = (props) => {
277275
applyUpdateV2(
278276
collabSessionDataRef.current.doc,
279277
new Uint8Array(update),
280-
uid
278+
uid1
281279
);
282280
resolve();
283281
} else {

frontend/src/pages/CollabSandbox/index.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ const CollabSandbox: React.FC = () => {
144144
>
145145
<CodeEditor
146146
editorState={collabSessionData}
147-
uid={collabUser.id}
148-
username={collabUser.username}
149147
language={language}
150148
template={
151149
language === "Python"
@@ -156,7 +154,6 @@ const CollabSandbox: React.FC = () => {
156154
? selectedQuestion.cTemplate
157155
: ""
158156
}
159-
roomId={roomId}
160157
/>
161158
</Box>
162159
<Box

0 commit comments

Comments
 (0)