Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 22 additions & 16 deletions web/core/components/pages/editor/editor-body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { IUserLite } from "@plane/types";
import { Row } from "@plane/ui";
import { PageContentBrowser, PageContentLoader, PageEditorTitle } from "@/components/pages";
// helpers
import { cn, LIVE_URL } from "@/helpers/common.helper";
import { cn, LIVE_BASE_PATH, LIVE_BASE_URL } from "@/helpers/common.helper";
import { generateRandomColor } from "@/helpers/string.helper";
// hooks
import { useMember, useMention, useUser, useWorkspace } from "@/hooks/store";
Expand Down Expand Up @@ -112,24 +112,30 @@ export const PageEditorBody: React.FC<Props> = observer((props) => {
[]
);

const realtimeConfig: TRealtimeConfig = useMemo(() => {
const realtimeConfig: TRealtimeConfig | undefined = useMemo(() => {
// Construct the WebSocket Collaboration URL
const WS_LIVE_URL = new URL(LIVE_URL);
const isSecureEnvironment = window.location.protocol === "https:";
WS_LIVE_URL.protocol = isSecureEnvironment ? "wss" : "ws";
WS_LIVE_URL.pathname = "collaboration";

return {
url: WS_LIVE_URL.toString(),
queryParams: {
workspaceSlug: workspaceSlug?.toString(),
projectId: projectId?.toString(),
documentType: "project_page",
},
};
try {
const LIVE_SERVER_BASE_URL = LIVE_BASE_URL ?? window.location.origin;
const WS_LIVE_URL = new URL(`${LIVE_SERVER_BASE_URL}${LIVE_BASE_PATH}`);
const isSecureEnvironment = window.location.protocol === "https:";
WS_LIVE_URL.protocol = isSecureEnvironment ? "wss" : "ws";
WS_LIVE_URL.pathname = "collaboration";
// Construct realtime config
return {
url: WS_LIVE_URL.toString(),
queryParams: {
workspaceSlug: workspaceSlug?.toString(),
projectId: projectId?.toString(),
documentType: "project_page",
},
};
} catch (error) {
console.error("Error creating realtime config", error);
return undefined;
}
}, [projectId, workspaceSlug]);

if (pageId === undefined) return <PageContentLoader />;
if (pageId === undefined || !realtimeConfig) return <PageContentLoader />;

return (
<div className="flex items-center h-full w-full overflow-y-auto">
Expand Down
2 changes: 1 addition & 1 deletion web/helpers/common.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const ADMIN_BASE_PATH = process.env.NEXT_PUBLIC_ADMIN_BASE_PATH || "";
export const SPACE_BASE_URL = process.env.NEXT_PUBLIC_SPACE_BASE_URL || "";
export const SPACE_BASE_PATH = process.env.NEXT_PUBLIC_SPACE_BASE_PATH || "";

const LIVE_BASE_URL = process.env.NEXT_PUBLIC_LIVE_BASE_URL || "";
export const LIVE_BASE_URL = process.env.NEXT_PUBLIC_LIVE_BASE_URL || "";
export const LIVE_BASE_PATH = process.env.NEXT_PUBLIC_LIVE_BASE_PATH || "";
export const LIVE_URL = `${LIVE_BASE_URL}${LIVE_BASE_PATH}`;

Expand Down