platform/lms-adm-fe release promotion snapshot
This commit is contained in:
@@ -3,7 +3,8 @@ import { ArrowLeft, ChevronRight, Loader2, MessageCircle, Send, UserRound, X } f
|
|||||||
import { io } from 'socket.io-client';
|
import { io } from 'socket.io-client';
|
||||||
import type { Socket } from 'socket.io-client';
|
import type { Socket } from 'socket.io-client';
|
||||||
import {
|
import {
|
||||||
CHAT_SOCKET_BASE_URL,
|
CHAT_SOCKET_ORIGIN,
|
||||||
|
CHAT_SOCKET_PATH,
|
||||||
createInstructorChatMessage,
|
createInstructorChatMessage,
|
||||||
getInstructorChatThread,
|
getInstructorChatThread,
|
||||||
listInstructorChatThreads,
|
listInstructorChatThreads,
|
||||||
@@ -100,8 +101,9 @@ export function InstructorChatPanel({ session, open, initialThreadId = null, ini
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
const socket: Socket = io(CHAT_SOCKET_BASE_URL, {
|
const socket: Socket = io(CHAT_SOCKET_ORIGIN, {
|
||||||
auth: { token: session.accessToken },
|
auth: { token: session.accessToken },
|
||||||
|
path: CHAT_SOCKET_PATH,
|
||||||
transports: ['websocket', 'polling'],
|
transports: ['websocket', 'polling'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import { InstructorChatPanel } from '../components/InstructorChatPanel';
|
|||||||
import { useToast } from '../components/ToastProvider';
|
import { useToast } from '../components/ToastProvider';
|
||||||
import autonomyLogo from '../assets/icon.png';
|
import autonomyLogo from '../assets/icon.png';
|
||||||
import { useProfileAvatar } from '../hooks/useProfileAvatar';
|
import { useProfileAvatar } from '../hooks/useProfileAvatar';
|
||||||
import { CHAT_SOCKET_BASE_URL } from '../lib/chat';
|
import { CHAT_SOCKET_ORIGIN, CHAT_SOCKET_PATH } from '../lib/chat';
|
||||||
import type { InstructorCourse } from '../lib/courses';
|
import type { InstructorCourse } from '../lib/courses';
|
||||||
import { deleteProfileAvatar, notifyProfileAvatarDeleted, notifyProfileAvatarUpdated, resizeImageToWebp, uploadProfileAvatar } from '../lib/profileAvatar';
|
import { deleteProfileAvatar, notifyProfileAvatarDeleted, notifyProfileAvatarUpdated, resizeImageToWebp, uploadProfileAvatar } from '../lib/profileAvatar';
|
||||||
import { navItems, type AppRoute } from '../routes';
|
import { navItems, type AppRoute } from '../routes';
|
||||||
@@ -157,8 +157,9 @@ export function InstructorLayout({ session, route, onNavigate, onLogout, courses
|
|||||||
}, [notificationPage, notificationTotalPages]);
|
}, [notificationPage, notificationTotalPages]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const socket: Socket = io(CHAT_SOCKET_BASE_URL, {
|
const socket: Socket = io(CHAT_SOCKET_ORIGIN, {
|
||||||
auth: { token: session.accessToken },
|
auth: { token: session.accessToken },
|
||||||
|
path: CHAT_SOCKET_PATH,
|
||||||
transports: ['websocket', 'polling'],
|
transports: ['websocket', 'polling'],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ export type InstructorChatThread = {
|
|||||||
|
|
||||||
const CHAT_API_BASE_URL = (import.meta.env.VITE_API_BASE_URL ?? 'https://workspace.autonomystudio.net/lms-api/api').replace(/\/+$/, '');
|
const CHAT_API_BASE_URL = (import.meta.env.VITE_API_BASE_URL ?? 'https://workspace.autonomystudio.net/lms-api/api').replace(/\/+$/, '');
|
||||||
export const CHAT_SOCKET_BASE_URL = CHAT_API_BASE_URL.replace(/\/api$/, '');
|
export const CHAT_SOCKET_BASE_URL = CHAT_API_BASE_URL.replace(/\/api$/, '');
|
||||||
|
const CHAT_SOCKET_URL = new URL(CHAT_SOCKET_BASE_URL || '/', window.location.origin);
|
||||||
|
const CHAT_SOCKET_PREFIX = CHAT_SOCKET_URL.pathname.replace(/\/+$/, '');
|
||||||
|
export const CHAT_SOCKET_ORIGIN = CHAT_SOCKET_URL.origin;
|
||||||
|
export const CHAT_SOCKET_PATH = `${CHAT_SOCKET_PREFIX}/socket.io`;
|
||||||
|
|
||||||
type ChatThreadsPayload = {
|
type ChatThreadsPayload = {
|
||||||
threads?: unknown[];
|
threads?: unknown[];
|
||||||
|
|||||||
Reference in New Issue
Block a user