Skip to content

Commit

Permalink
VUU-47 improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
vferraro-scottlogic committed Oct 2, 2023
1 parent 13283dd commit 4c036e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export interface LayoutPersistenceManager {
*
* @returns Full JSON representation of a layouts
*/
loadTempLayout: () => Promise<LayoutJSON>;
loadCurrentLayout: () => Promise<LayoutJSON>;

/**
* Saves a temporary layout
*
* @param layout - Full JSON representation of layout to be saved
*/
saveTempLayout: (layout: LayoutJSON) => Promise<void>
saveCurrentLayout: (layout: LayoutJSON) => Promise<void>
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ export class LocalLayoutPersistenceManager implements LayoutPersistenceManager {
});
}

loadTempLayout(): Promise<LayoutJSON> {
return new Promise((resolve, reject) => {
const tempLayout = getLocalEntity<LayoutJSON>("api/vui");
if (tempLayout) {
resolve(tempLayout);
loadCurrentLayout(): Promise<LayoutJSON> {
return new Promise((resolve) => {
const currentLayout = getLocalEntity<LayoutJSON>("api/vui");
if (currentLayout) {
resolve(currentLayout);
} else {
resolve(defaultLayout);
}
});
}

saveTempLayout(layout: LayoutJSON): Promise<void> {
saveCurrentLayout(layout: LayoutJSON): Promise<void> {
return new Promise((resolve, reject) => {
const savedLayout = saveLocalEntity<LayoutJSON>("api/vui", layout);
if (savedLayout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ export const LayoutManagementProvider = (props: LayoutManagementProviderProps) =
const [currentLayout, setCurrentLayout] = useState<LayoutJSON>(defaultLayout);

useEffect(() => {
Promise.all([persistenceManager.loadMetadata(), persistenceManager.loadTempLayout()])
.then(([metadata, layout]) => {
setLayoutMetadata(metadata)
setCurrentLayout(layout);
})
persistenceManager.loadMetadata().then(metadata => {
setLayoutMetadata(metadata)
})
persistenceManager.loadCurrentLayout().then(layout => {
setCurrentLayout(layout);
})
}, [])

const saveCurrentLayout = useCallback((layout: LayoutJSON) => {
setCurrentLayout(layout)
persistenceManager.saveTempLayout(layout)
persistenceManager.saveCurrentLayout(layout)
}, []);

const saveLayout = useCallback((metadata: Omit<LayoutMetadata, "id">) => {
Expand Down

0 comments on commit 4c036e1

Please sign in to comment.