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 = [
|
||||
'#chat-button',
|
||||
'button[id="chat-button"]',
|
||||
'button[aria-label="Chat"]',
|
||||
'button[aria-label*="Chat" i]',
|
||||
'button[aria-label*="Unterhaltung" i]',
|
||||
|
|
@ -133,11 +132,21 @@ export class ChatProcedure {
|
|||
'button[aria-label*="Meeting chat" i]',
|
||||
];
|
||||
|
||||
// Poll for the chat button (toolbar renders asynchronously after join)
|
||||
const maxAttempts = 10;
|
||||
const pollIntervalMs = 1500;
|
||||
// Poll for the chat button (toolbar renders asynchronously after join).
|
||||
// IMPORTANT: click only ONCE per attempt, then wait for the panel to appear.
|
||||
// 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++) {
|
||||
// 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) {
|
||||
try {
|
||||
const button = await this._page.$(selector);
|
||||
|
|
@ -145,23 +154,35 @@ export class ChatProcedure {
|
|||
const isVisible = await button.isVisible().catch(() => false);
|
||||
if (!isVisible) continue;
|
||||
await button.click();
|
||||
this._logger.info(`Opened chat panel via: ${selector} (attempt ${attempt}/${maxAttempts})`);
|
||||
await this._page.waitForTimeout(1500);
|
||||
if (await this._isChatPanelOpen()) return;
|
||||
this._logger.info(`Clicked ${selector} but panel not detected as open yet`);
|
||||
clicked = true;
|
||||
this._logger.info(`Clicked chat button: ${selector} (attempt ${attempt}/${maxAttempts})`);
|
||||
break;
|
||||
}
|
||||
} catch {
|
||||
// Continue
|
||||
// Continue to next selector
|
||||
}
|
||||
}
|
||||
|
||||
if (attempt < maxAttempts) {
|
||||
this._logger.info(`Chat button not found yet, retry ${attempt}/${maxAttempts} in ${pollIntervalMs}ms`);
|
||||
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) {
|
||||
this._logger.info(`Chat button not found, retry ${attempt}/${maxAttempts}`);
|
||||
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