mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-22 02:11:29 +00:00
Migrate Most Recent activity local storage to App State persistence (#1967)
* Rewrite MostRecentActivity to leverage AppStatePersistenceUtility. * Fix format. Update type enum. * Migrate Item enum to string enum * Fix unit tests * Fix build issue
This commit is contained in:
@@ -3,6 +3,7 @@ import { LocalStorageUtility, StorageKey } from "Shared/StorageUtility";
|
||||
// The component name whose state is being saved. Component name must not include special characters.
|
||||
export enum AppStateComponentNames {
|
||||
DocumentsTab = "DocumentsTab",
|
||||
MostRecentActivity = "MostRecentActivity",
|
||||
QueryCopilot = "QueryCopilot",
|
||||
}
|
||||
|
||||
@@ -34,6 +35,7 @@ export const loadState = (path: StorePath): unknown => {
|
||||
const key = createKeyFromPath(path);
|
||||
return appState[key]?.data;
|
||||
};
|
||||
|
||||
export const saveState = (path: StorePath, state: unknown): void => {
|
||||
// Retrieve state object
|
||||
const appState =
|
||||
@@ -65,6 +67,10 @@ export const deleteState = (path: StorePath): void => {
|
||||
LocalStorageUtility.setEntryObject(StorageKey.AppState, appState);
|
||||
};
|
||||
|
||||
export const hasState = (path: StorePath): boolean => {
|
||||
return loadState(path) !== undefined;
|
||||
};
|
||||
|
||||
// This is for high-frequency state changes
|
||||
let timeoutId: NodeJS.Timeout | undefined;
|
||||
export const saveStateDebounced = (path: StorePath, state: unknown, debounceDelayMs = 1000): void => {
|
||||
|
||||
@@ -24,7 +24,7 @@ export enum StorageKey {
|
||||
MaxDegreeOfParellism,
|
||||
IsGraphAutoVizDisabled,
|
||||
TenantId,
|
||||
MostRecentActivity,
|
||||
MostRecentActivity, // deprecated
|
||||
SetPartitionKeyUndefined,
|
||||
GalleryCalloutDismissed,
|
||||
VisitedAccounts,
|
||||
|
||||
Reference in New Issue
Block a user