Skip to content

Commit 19692a3

Browse files
committed
apply cell updates optimistically rather than waiting until the change is successfully committed to IndexedDB
1 parent afc49c5 commit 19692a3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
77

88
### Added
99

10+
- Optimistically update cell values before saving the value to IndexedDB but revert it in case of failures. This makes
11+
the update faster from a user perspective since we don't wait for it to be committed to IndexedDB first.
1012
- Distinguish the extension installed in dev mode from the one installed from the Chrome Web Store.
1113

1214
## [1.0.1] - 2025-11-28

src/devtools/components/main-content/object-store-view/Table.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,12 @@ export default function Table(props: TableProps) {
206206
setErrorMsg(`Cell update reverted: ${DATA_MUTATION_ERROR_MSG}`);
207207
return;
208208
}
209+
// store the old value in case the update in indexedDB fails
210+
const oldValue = params.data[col.name];
209211
let newValue = parseBooleanNull(params.newValue, col.datatype);
210212
newValue = convertGetterValueToRowDataValue(newValue, col.datatype);
213+
// optimistically update the cell value
214+
updateRowData(params.api, params.data, col, newValue);
211215

212216
try {
213217
await updateField({
@@ -218,9 +222,8 @@ export default function Table(props: TableProps) {
218222
fieldToUpdate,
219223
newValue: { value: newValue, datatype: col.datatype },
220224
});
221-
// after the update succeeded in indexedDB, update the table data
222-
updateRowData(params.api, params.data, col, newValue);
223225
} catch (e) {
226+
updateRowData(params.api, params.data, col, oldValue);
224227
const msg = e instanceof Error ? e.message : DATA_MUTATION_ERROR_MSG;
225228
setErrorMsg(`Cell update reverted: ${msg}`);
226229
}

0 commit comments

Comments
 (0)