mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix error when canceling import
Summary: If cancel was clicked while a transform section was still being generated in the Importer, an error was thrown. This refactors the cancelImportFiles API action to take in the file upload id in place of the entire DataSourceTransformed parameter, which contains other values that are irrelevant to canceling. One of those values, the transform section id, was causing the error to be thrown since it was momentarily null. Test Plan: Tested manually. Reviewers: alexmojaki Reviewed By: alexmojaki Differential Revision: https://phab.getgrist.com/D3317
This commit is contained in:
parent
77a5d31afe
commit
f02174eb7e
@ -446,10 +446,8 @@ export class Importer extends DisposableWithEvents {
|
||||
this._resetImportDiffState();
|
||||
// Formula editor cleanup needs to happen before the hidden tables are removed.
|
||||
this._formulaEditorHolder.dispose();
|
||||
|
||||
if (this._uploadResult) {
|
||||
await this._docComm.cancelImportFiles(
|
||||
this._getTransformedDataSource(this._uploadResult), this._getHiddenTableIds());
|
||||
await this._docComm.cancelImportFiles(this._uploadResult.uploadId, this._getHiddenTableIds());
|
||||
}
|
||||
this._screen.close();
|
||||
this.dispose();
|
||||
|
@ -209,7 +209,7 @@ export interface ActiveDocAPI {
|
||||
/**
|
||||
* Cancels import files, cleans up temporary hidden tables and uploads.
|
||||
*/
|
||||
cancelImportFiles(dataSource: DataSourceTransformed, prevTableIds: string[]): Promise<void>;
|
||||
cancelImportFiles(uploadId: number, prevTableIds: string[]): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a diff of changes that will be applied to the destination table from `transformRule`
|
||||
|
@ -544,9 +544,9 @@ export class ActiveDoc extends EventEmitter {
|
||||
* Param `prevTableIds` is an array of hiddenTableIds as received from previous `importFiles`
|
||||
* call, or empty if there was no previous call.
|
||||
*/
|
||||
public cancelImportFiles(docSession: DocSession, dataSource: DataSourceTransformed,
|
||||
public cancelImportFiles(docSession: DocSession, uploadId: number,
|
||||
prevTableIds: string[]): Promise<void> {
|
||||
return this._activeDocImport.cancelImportFiles(docSession, dataSource, prevTableIds);
|
||||
return this._activeDocImport.cancelImportFiles(docSession, uploadId, prevTableIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -97,17 +97,17 @@ export class ActiveDocImport {
|
||||
* Cancels import files, removes temporary hidden tables and temporary uploaded files
|
||||
*
|
||||
* @param {ActiveDoc} activeDoc: Instance of ActiveDoc.
|
||||
* @param {DataSourceTransformed} dataSource: an array of DataSource
|
||||
* @param {number} uploadId: Identifier for the temporary uploaded file(s) to clean up.
|
||||
* @param {Array<String>} prevTableIds: Array of tableIds as received from previous `importFiles`
|
||||
* call when re-importing with changed `parseOptions`.
|
||||
* @returns {Promise} Promise that's resolved when all actions are applied successfully.
|
||||
*/
|
||||
public async cancelImportFiles(docSession: DocSession,
|
||||
dataSource: DataSourceTransformed,
|
||||
uploadId: number,
|
||||
prevTableIds: string[]): Promise<void> {
|
||||
await this._removeHiddenTables(docSession, prevTableIds);
|
||||
this._activeDoc.stopBundleUserActions(docSession);
|
||||
await globalUploadSet.cleanup(dataSource.uploadId);
|
||||
await globalUploadSet.cleanup(uploadId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user