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 2973f7d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions how-to/workspace-platform-starter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Added support for dock submenus
- Added support for customizing the taskbar icon for the splash screen window
- Added an example of navigating content using navigation controls. Enabled through default window options in the main [manifest.fin.json](./public/manifest.fin.json) and in our developer docs snapshot [developer.snapshot.fin.json](./public/common/snapshots/developer.snapshot.fin.json)
- Fixed an issue where the order of entries within dock would change when toggling between light and dark theme.

## v16.1.0

Expand Down
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 2973f7d

Please sign in to comment.