import { SYSTEM_DEFAULT } from "../../../../../constant"; /** * The per-toolbar prefix every session-storage key in this package is built * from: the group id, prefixed with the host's unique view id when it supplies * one. * * `getUniqueViewId` is invoked synchronously by every known host; if a host ever * calls back later the key falls back to the bare group id, exactly as the * inline copies did. */ export const getSessionKeyPrefix = ( uiElementGroupId: string, getUniqueViewId?: (callBack: (response: string) => void) => void, ): string => { let uniqueViewId = uiElementGroupId; if (getUniqueViewId) { getUniqueViewId((id: string) => { uniqueViewId = id + "-" + uiElementGroupId; }); } return uniqueViewId; }; /** * Session-storage key holding the System Default view's configuration * (`enableDefaultSaveInSession`). * * `UserView` built this key inline in three places — reset, load and now the * copy-source lookup — each repeating the same "prefix with the unique view id * if the host supplies one" dance. One definition keeps the writer * (`saveSystemDefaultInSession`) and every reader on the same key. */ export const getSystemDefaultSessionKey = ( uiElementGroupId: string, getUniqueViewId?: (callBack: (response: string) => void) => void, ): string => `${getSessionKeyPrefix(uiElementGroupId, getUniqueViewId)}_${SYSTEM_DEFAULT}`; export default getSystemDefaultSessionKey;