Skip to content

Commit 951921e

Browse files
committed
Update updateButtonsForProfileChange function: require origin parameter and add warnings for invalid calls
1 parent 40b40c8 commit 951921e

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

buttons-init.js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,16 @@ window.MaxExtensionButtonsInit = {
175175

176176
/**
177177
* Updates all buttons and toggles in response to a profile change.
178-
* Accepts an optional `origin` parameter:
178+
* Requires an `origin` parameter to specify which UI to update:
179179
* - 'panel' => only update the floating panel UI
180180
* - 'inline' => only update the inline buttons UI
181-
* - null/undefined => update both (legacy behavior)
182181
*/
183-
updateButtonsForProfileChange: function (origin = null) {
182+
updateButtonsForProfileChange: function (origin) {
183+
if (!origin) {
184+
logConCgp('[init] Warning: updateButtonsForProfileChange called without origin parameter. No action taken.');
185+
return;
186+
}
187+
184188
// If origin is 'panel', only update the floating panel
185189
if (origin === 'panel') {
186190
if (window.MaxExtensionFloatingPanel && window.MaxExtensionFloatingPanel.panelElement) {
@@ -204,23 +208,8 @@ window.MaxExtensionButtonsInit = {
204208
}
205209
return;
206210
}
207-
208-
// Legacy/default: update both containers
209-
const originalContainer = document.getElementById(window.InjectionTargetsOnWebsite.selectors.buttonsContainerId);
210-
if (originalContainer) {
211-
originalContainer.innerHTML = '';
212-
this.generateAndAppendAllButtons(originalContainer, false); // Not panel
213-
logConCgp('[init] Updated buttons in original container for profile change.');
214-
}
215-
216-
if (window.MaxExtensionFloatingPanel && window.MaxExtensionFloatingPanel.panelElement) {
217-
const panelContent = document.getElementById('max-extension-floating-panel-content');
218-
if (panelContent) {
219-
panelContent.innerHTML = '';
220-
this.generateAndAppendAllButtons(panelContent, true); // This is the panel
221-
logConCgp('[init] Updated buttons in floating panel for profile change.');
222-
}
223-
}
211+
212+
logConCgp(`[init] Warning: updateButtonsForProfileChange called with unknown origin '${origin}'. No action taken.`);
224213
}
225214
};
226215

0 commit comments

Comments
 (0)