Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: retain dock order when lifecycle conditions are triggered #676

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading