chore: consolidate sqllab store into SPA store (#25088)

This commit is contained in:
JUST.in DO IT
2023-08-30 16:09:57 -07:00
committed by GitHub
parent eeecd59c9d
commit 846c79ef55
7 changed files with 152 additions and 98 deletions

View File

@@ -17,6 +17,7 @@
* under the License.
*/
import pick from 'lodash/pick';
import { tableApiUtil } from 'src/hooks/apiResources/tables';
import {
BYTES_PER_CHAR,
KB_STORAGE,
@@ -96,3 +97,25 @@ export function clearQueryEditors(queryEditors) {
),
);
}
export function rehydratePersistedState(dispatch, state) {
// Rehydrate server side persisted table metadata
state.sqlLab.tables.forEach(({ name: table, schema, dbId, persistData }) => {
if (dbId && schema && table && persistData?.columns) {
dispatch(
tableApiUtil.upsertQueryData(
'tableMetadata',
{ dbId, schema, table },
persistData,
),
);
dispatch(
tableApiUtil.upsertQueryData(
'tableExtendedMetadata',
{ dbId, schema, table },
{},
),
);
}
});
}