Skip to content

Commit

Permalink
fix: retain dock order when lifecycle conditions are triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
camc314 committed Jan 30, 2024
1 parent de5df51 commit 9da1398
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,33 @@ export async function saveConfig(
config: DockProviderConfigWithIdentity,
defaultStorage: (config: DockProviderConfigWithIdentity) => Promise<void>
): Promise<void> {
// we need to store the new stored config in the dockProviderOptions
if (dockProviderOptions?.entries) {
const orderedButtons: DockButtonTypes[] = [];

// store the buttons in a map for fast, easy lookup
const currentButtons = new Map<string, DockButtonTypes>();
for (const entry of dockProviderOptions.entries) {
currentButtons.set(entry.id, entry);
}

// new extract the new buttons from the config
for (const button of config.buttons ?? []) {
if (isStringValue(button.id)) {
const foundButton = currentButtons.get(button.id);
if (foundButton) {
orderedButtons.push(foundButton);
currentButtons.delete(button.id);
}
}
}

// add any remaining buttons that we failed to find in the config
orderedButtons.push(...currentButtons.values());

dockProviderOptions.entries = orderedButtons;
}

logger.info(`Checking for custom dock storage with endpoint id: ${DOCK_ENDPOINT_ID_SET}`);

if (endpointProvider.hasEndpoint(DOCK_ENDPOINT_ID_SET)) {
Expand Down

0 comments on commit 9da1398

Please sign in to comment.