fix: тема доски синхронизируется между учителем и учениками в реальном времени
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+19
-3
@@ -3160,6 +3160,7 @@
|
||||
let _me = null;
|
||||
let _session = null;
|
||||
let _sessionId = null;
|
||||
let _sessionBoardTheme = null; // pending theme from session data, applied in initWhiteboard
|
||||
let _sseHandle = null;
|
||||
let _participants = {}; // userId -> {name, micMuted}
|
||||
let _raisedHands = {}; // userId -> userName
|
||||
@@ -3554,6 +3555,12 @@
|
||||
if (sel) sel.value = data.template;
|
||||
wbUpdateThumbnail(_wbCurrentPage);
|
||||
}
|
||||
} else if (data.type === 'classroom_board_theme') {
|
||||
if (_sessionId == data.sessionId && _wb) {
|
||||
_wb.setBoardTheme(data.theme);
|
||||
const sel = document.getElementById('wb-theme-select');
|
||||
if (sel) sel.value = data.theme;
|
||||
}
|
||||
} else if (data.type === 'classroom_hand_raised') {
|
||||
if (_sessionId == data.sessionId) onHandRaised(data.userId, data.userName);
|
||||
} else if (data.type === 'classroom_hand_lowered') {
|
||||
@@ -3981,6 +3988,8 @@
|
||||
// page state
|
||||
_wbCurrentPage = session.current_page || 1;
|
||||
_totalPages = session.pageCount || 1;
|
||||
// Remember board theme from session — will be applied in initWhiteboard
|
||||
if (session.board_theme) _sessionBoardTheme = session.board_theme;
|
||||
_raisedHands = {};
|
||||
_handRaised = false;
|
||||
_followTeacher = true;
|
||||
@@ -4069,8 +4078,12 @@
|
||||
stylusMultiplier: _prefs.stylusMultiplier,
|
||||
});
|
||||
|
||||
// Sync board theme selector to whiteboard default
|
||||
{ const sel = document.getElementById('wb-theme-select'); if (sel) sel.value = 'chalkboard'; }
|
||||
// Apply session board theme (set by teacher, synced for all participants)
|
||||
if (_sessionBoardTheme && _sessionBoardTheme !== 'chalkboard') {
|
||||
_wb.setBoardTheme(_sessionBoardTheme);
|
||||
}
|
||||
{ const sel = document.getElementById('wb-theme-select'); if (sel) sel.value = _sessionBoardTheme || 'chalkboard'; }
|
||||
_sessionBoardTheme = null; // consumed
|
||||
|
||||
// Apply saved whiteboard defaults from user preferences
|
||||
if (canEdit && LS.prefs) {
|
||||
@@ -5508,10 +5521,13 @@
|
||||
function wbSetBoardTheme(theme) {
|
||||
if (!_wb) return;
|
||||
_wb.setBoardTheme(theme);
|
||||
// Update selector if called programmatically
|
||||
const sel = document.getElementById('wb-theme-select');
|
||||
if (sel) sel.value = theme;
|
||||
if (LS.prefs) LS.prefs.set('wb.theme', theme);
|
||||
// Broadcast to students if in active session
|
||||
if (_sessionId) {
|
||||
LS.patch(`/api/classroom/${_sessionId}/board-theme`, { theme }).catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Page context menu ── */
|
||||
|
||||
Reference in New Issue
Block a user