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:
Laurent Nguyen
2024-09-20 08:26:58 +02:00
committed by GitHub
parent 869d81dfbc
commit 23b2e59560
7 changed files with 197 additions and 209 deletions

View File

@@ -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 => {

View File

@@ -24,7 +24,7 @@ export enum StorageKey {
MaxDegreeOfParellism,
IsGraphAutoVizDisabled,
TenantId,
MostRecentActivity,
MostRecentActivity, // deprecated
SetPartitionKeyUndefined,
GalleryCalloutDismissed,
VisitedAccounts,