Skip to content

Commit

Permalink
Fix embed view regression
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Jan 7, 2025
1 parent 12c241a commit 14a1940
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions client/analysisCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class AnalysisController extends GameController {
constructor(el: HTMLElement, model: PyChessModel) {
super(el, model, model.fen, document.getElementById('pocket0') as HTMLElement, document.getElementById('pocket1') as HTMLElement, '');
this.fsfError = [];
this.embed = this.gameId === undefined;
this.embed = model.embed;
this.puzzle = model["puzzle"] !== "";
this.isAnalysisBoard = this.gameId === "" && !this.puzzle;
if (!this.embed) {
Expand Down Expand Up @@ -214,7 +214,7 @@ export class AnalysisController extends GameController {

setAriaTabClick("analysis_tab");

if (!this.puzzle && !this.ongoing) {
if (!this.puzzle && !this.ongoing && !this.embed) {
const initialEl = document.querySelector('[tabindex="0"]') as HTMLElement;
initialEl.setAttribute('aria-selected', 'true');
(initialEl!.parentNode!.parentNode!.querySelector(`#${initialEl.getAttribute('aria-controls')}`)! as HTMLElement).style.display = 'block';
Expand Down
25 changes: 15 additions & 10 deletions client/gameCtrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,9 @@ export abstract class GameController extends ChessgroundController implements Ch

private onMsgSpectators = (msg: MsgSpectators) => {
const container = document.getElementById('spectators') as HTMLElement;
patch(container, h('under-left#spectators', _('Spectators: ') + msg.spectators));
if (container) {
patch(container, h('under-left#spectators', _('Spectators: ') + msg.spectators));
}
}

private onMsgChat = (msg: MsgChat) => {
Expand All @@ -505,15 +507,18 @@ export abstract class GameController extends ChessgroundController implements Ch
}

private onMsgFullChat = (msg: MsgFullChat) => {
// To prevent multiplication of messages we have to remove old messages div first
patch(document.getElementById('messages') as HTMLElement, h('div#messages-clear'));
// then create a new one
patch(document.getElementById('messages-clear') as HTMLElement, h('div#messages'));
msg.lines.forEach((line) => {
if ((this.spectator && line.room === 'spectator') || (!this.spectator && line.room !== 'spectator') || line.user.length === 0) {
chatMessage(line.user, line.message, "roundchat", line.time);
}
});
const container = document.getElementById('messages') as HTMLElement;
if (container) {
// To prevent multiplication of messages we have to remove old messages div first
patch(container, h('div#messages-clear'));
// then create a new one
patch(document.getElementById('messages-clear') as HTMLElement, h('div#messages'));
msg.lines.forEach((line) => {
if ((this.spectator && line.room === 'spectator') || (!this.spectator && line.room !== 'spectator') || line.user.length === 0) {
chatMessage(line.user, line.message, "roundchat", line.time);
}
});
}
}

private onMsgGameNotFound = (msg: MsgGameNotFound) => {
Expand Down

0 comments on commit 14a1940

Please sign in to comment.