Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ext appStorage save as object OK-34155 #6410

Merged
merged 3 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: ext appStorage save object
  • Loading branch information
sidmorizon committed Dec 25, 2024
commit c59a3f067eac7e4c3f502976e50e71f8fc7617fd
2 changes: 1 addition & 1 deletion packages/shared/src/storage/appStorageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let _canSaveAsObject: boolean | null = null;
function canSaveAsObject(): boolean {
if (_canSaveAsObject === null) {
_canSaveAsObject = false;
if (platformEnv.isRuntimeBrowser) {
if (platformEnv.isRuntimeBrowser || platformEnv.isExtension) {
const isIndexedDB: boolean = (
appStorage as unknown as WebStorage
)?.isIndexedDB();
Expand Down
9 changes: 7 additions & 2 deletions packages/shared/src/storage/syncStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isPlainObject } from 'lodash';

import appGlobals from '../appGlobals';
import platformEnv from '../platformEnv';
import { ensureRunOnBackground } from '../utils/assertUtils';
import dbPerfMonitor from '../utils/debug/dbPerfMonitor';
import resetUtils from '../utils/resetUtils';

Expand Down Expand Up @@ -30,14 +31,18 @@ export const buildAppStorageFactory = (
const setItem: IAppStorage['setItem'] = (key, value, callback) => {
resetUtils.checkNotInResetting();
dbPerfMonitor.logAppStorageCall('setItem', key);
ensureRunOnBackground();
return originalSetItem.call(storage, key, value, callback);
};
const getItem: IAppStorage['getItem'] = (key, callback) => {
dbPerfMonitor.logAppStorageCall('getItem', key);
ensureRunOnBackground();
return originalGetItem.call(storage, key, callback);
};
const removeItem: IAppStorage['removeItem'] = (key, callback) =>
originalRemoveItem.call(storage, key, callback);
const removeItem: IAppStorage['removeItem'] = (key, callback) => {
ensureRunOnBackground();
return originalRemoveItem.call(storage, key, callback);
};

storage.setItem = setItem;
storage.getItem = getItem;
Expand Down
Loading