fix: Chat-Panel Toggle-Oszillation - nur 1x klicken pro Versuch, check vor erneutem Klick
Made-with: Cursor
This commit is contained in:
parent
baae7dca61
commit
6e444e83d0
1 changed files with 33 additions and 12 deletions
|
|
@ -125,7 +125,6 @@ export class ChatProcedure {
|
||||||
|
|
||||||
const chatButtonSelectors = [
|
const chatButtonSelectors = [
|
||||||
'#chat-button',
|
'#chat-button',
|
||||||
'button[id="chat-button"]',
|
|
||||||
'button[aria-label="Chat"]',
|
'button[aria-label="Chat"]',
|
||||||
'button[aria-label*="Chat" i]',
|
'button[aria-label*="Chat" i]',
|
||||||
'button[aria-label*="Unterhaltung" i]',
|
'button[aria-label*="Unterhaltung" i]',
|
||||||
|
|
@ -133,11 +132,21 @@ export class ChatProcedure {
|
||||||
'button[aria-label*="Meeting chat" i]',
|
'button[aria-label*="Meeting chat" i]',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Poll for the chat button (toolbar renders asynchronously after join)
|
// Poll for the chat button (toolbar renders asynchronously after join).
|
||||||
const maxAttempts = 10;
|
// IMPORTANT: click only ONCE per attempt, then wait for the panel to appear.
|
||||||
const pollIntervalMs = 1500;
|
// Multiple clicks on the same toggle button would open/close/open/close.
|
||||||
|
const maxAttempts = 12;
|
||||||
|
const pollIntervalMs = 2000;
|
||||||
|
|
||||||
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
||||||
|
// Check first - a previous click might have opened it by now
|
||||||
|
if (await this._isChatPanelOpen()) {
|
||||||
|
this._logger.info(`Chat panel detected as open (attempt ${attempt})`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to find and click the button (only one click per attempt)
|
||||||
|
let clicked = false;
|
||||||
for (const selector of chatButtonSelectors) {
|
for (const selector of chatButtonSelectors) {
|
||||||
try {
|
try {
|
||||||
const button = await this._page.$(selector);
|
const button = await this._page.$(selector);
|
||||||
|
|
@ -145,23 +154,35 @@ export class ChatProcedure {
|
||||||
const isVisible = await button.isVisible().catch(() => false);
|
const isVisible = await button.isVisible().catch(() => false);
|
||||||
if (!isVisible) continue;
|
if (!isVisible) continue;
|
||||||
await button.click();
|
await button.click();
|
||||||
this._logger.info(`Opened chat panel via: ${selector} (attempt ${attempt}/${maxAttempts})`);
|
clicked = true;
|
||||||
await this._page.waitForTimeout(1500);
|
this._logger.info(`Clicked chat button: ${selector} (attempt ${attempt}/${maxAttempts})`);
|
||||||
if (await this._isChatPanelOpen()) return;
|
break;
|
||||||
this._logger.info(`Clicked ${selector} but panel not detected as open yet`);
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Continue
|
// Continue to next selector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clicked) {
|
||||||
|
// Wait for panel to render after click
|
||||||
|
await this._page.waitForTimeout(2500);
|
||||||
|
if (await this._isChatPanelOpen()) {
|
||||||
|
this._logger.info('Chat panel opened successfully');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Panel didn't open despite click - DON'T click again immediately,
|
||||||
|
// wait for next attempt cycle (avoids toggle oscillation)
|
||||||
|
this._logger.info('Chat button clicked but panel not detected yet, waiting before next attempt');
|
||||||
|
await this._page.waitForTimeout(pollIntervalMs);
|
||||||
|
} else {
|
||||||
if (attempt < maxAttempts) {
|
if (attempt < maxAttempts) {
|
||||||
this._logger.info(`Chat button not found yet, retry ${attempt}/${maxAttempts} in ${pollIntervalMs}ms`);
|
this._logger.info(`Chat button not found, retry ${attempt}/${maxAttempts}`);
|
||||||
await this._page.waitForTimeout(pollIntervalMs);
|
await this._page.waitForTimeout(pollIntervalMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this._logger.warn('Could not find chat button after polling - chat will not work');
|
this._logger.warn('Could not open chat panel after polling - chat will not work');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue