Query History: Refactor persistence layer (#44545)

* Extract Rich History storage into two separate implementations

Implement getting all entries and adding a new entry

* Add deleting rich history items

* Add editing rich history

* Simplify RichHistoryStorage API

* Reorganize methods

* Rename variable

* Remove feature toggle

* Fix TS errors

* Fix tests

* Clean up

* Clean up only when adding new entry

* Fix showing a warning message

* Use enum instead of a string

* Update public/app/core/history/richHistoryLocalStorage.ts

Co-authored-by: Giordano Ricci <me@giordanoricci.com>

* Update public/app/core/history/richHistoryLocalStorage.ts

Co-authored-by: Giordano Ricci <me@giordanoricci.com>

* Improve readability

* Rename files and remove inferred return types

* Use const over a var

* Remove unsed files

* Remove redundant null check

* Update public/app/core/history/richHistoryLocalStorageUtils.ts

Co-authored-by: Giordano Ricci <me@giordanoricci.com>

* Fix linting issues

Co-authored-by: Giordano Ricci <me@giordanoricci.com>
This commit is contained in:
Piotr Jamróz
2022-02-04 12:46:27 +01:00
committed by GitHub
parent 9e52361c1e
commit 6bb6b13379
18 changed files with 683 additions and 364 deletions

View File

@@ -20,7 +20,7 @@ export interface SyncTimesPayload {
export const syncTimesAction = createAction<SyncTimesPayload>('explore/syncTimes');
export const richHistoryUpdatedAction = createAction<any>('explore/richHistoryUpdated');
export const localStorageFullAction = createAction('explore/localStorageFullAction');
export const richHistoryStorageFullAction = createAction('explore/richHistoryStorageFullAction');
export const richHistoryLimitExceededAction = createAction('explore/richHistoryLimitExceededAction');
/**
@@ -158,7 +158,7 @@ export const initialExploreState: ExploreState = {
left: initialExploreItemState,
right: undefined,
richHistory: [],
localStorageFull: false,
richHistoryStorageFull: false,
richHistoryLimitExceededWarningShown: false,
};
@@ -214,10 +214,10 @@ export const exploreReducer = (state = initialExploreState, action: AnyAction):
};
}
if (localStorageFullAction.match(action)) {
if (richHistoryStorageFullAction.match(action)) {
return {
...state,
localStorageFull: true,
richHistoryStorageFull: true,
};
}