Skip to content

Commit

Permalink
Include snapshot when saving and set up config listener earlier.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnman committed Jun 21, 2024
1 parent 4da1e25 commit bf01227
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type OpenFin from "@openfin/core";
import type { PlatformLayoutSnapshot } from "../../shapes/layout-shapes";
import type { Logger } from "../../shapes/logger-shapes";
import type { SettingsResolverOptions, SettingsResolverResponse } from "../../shapes/setting-shapes";
import type {
Settings,
SettingsResolverOptions,
SettingsResolverResponse
} from "../../shapes/setting-shapes";
import { objectClone } from "../../utils";
import { clearSettings, getSettings, saveSettings } from "./settings";

/**
Expand Down Expand Up @@ -78,7 +84,10 @@ export class SettingsResolverHelper {
response.settingsResolverResponse.action === "save-reload" &&
response.settingsResolverResponse.settings
) {
await saveSettings(response.settingsResolverResponse.settings);
const settingsToSave = objectClone<Settings>(response.settingsResolverResponse.settings);
const layoutManager = fin.Platform.Layout.getCurrentLayoutManagerSync<PlatformLayoutSnapshot>();
settingsToSave.platform.layout.defaultLayout = await layoutManager.getLayoutSnapshot();
await saveSettings(settingsToSave);
location.reload();
} else if (response.settingsResolverResponse.action === "reset-reload") {
await clearSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ async function init(): Promise<void> {
return;
}

listenForConfigRequests(settings);

// Connect to the OpenFin Web Broker and pass the default layout.
// It is good practice to specify providerId even if content is explicitly specifying it for cases where
// this provider uses our layout system and content uses inheritance. currentContextGroup
Expand All @@ -183,8 +185,6 @@ async function init(): Promise<void> {
platform: { layoutSnapshot }
});

listenForConfigRequests(settings);

if (fin) {
// Store the fin object in the window object for easy access.
window.fin = fin;
Expand Down

0 comments on commit bf01227

Please sign in to comment.