Fix rest of notebook unhandled promises (#16933)

* Fix rest of notebook unhandled promises

* add rule

* fix some tests
This commit is contained in:
Charles Gagnon
2021-08-30 14:14:48 -07:00
committed by GitHub
parent 26e08fdf9e
commit 76e01fee60
21 changed files with 79 additions and 53 deletions

View File

@@ -48,7 +48,7 @@ export class BookModel {
public watchTOC(): void {
fs.watchFile(this.tableOfContentsPath, async (curr, prev) => {
if (curr.mtime > prev.mtime) {
this.reinitializeContents();
this.reinitializeContents().catch(err => console.error('Error reinitializing book contents ', err));
}
});
}

View File

@@ -346,7 +346,7 @@ export class BookTocManager implements IBookTocManager {
const movedSections = await this.traverseSections(files);
this.newSection.sections = movedSections;
this._modifiedDirectory.add(path.dirname(section.book.contentPath));
this.cleanUp(path.dirname(section.book.contentPath));
await this.cleanUp(path.dirname(section.book.contentPath));
}
if (bookItem.book.version === BookVersion.v1) {

View File

@@ -155,8 +155,8 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
async createBook(): Promise<void> {
const dialog = new CreateBookDialog(this.bookTocManager);
dialog.createDialog();
TelemetryReporter.sendActionEvent(BookTelemetryView, NbTelemetryActions.CreateBook);
return dialog.createDialog();
}
async getSelectionQuickPick(movingElement: BookTreeItem): Promise<quickPickResults> {
@@ -237,7 +237,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
if (showPreview) {
this.currentBook = this.books.find(book => book.bookPath === bookPath);
this._bookViewer.reveal(this.currentBook.bookItems[0], { expand: vscode.TreeItemCollapsibleState.Expanded, focus: true, select: true });
await this._bookViewer.reveal(this.currentBook.bookItems[0], { expand: vscode.TreeItemCollapsibleState.Expanded, focus: true, select: true });
await this.showPreviewFile(urlToOpen);
}

View File

@@ -76,7 +76,7 @@ export class BookTrustManager implements IBookTrustManager {
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(constants.notebookConfigKey);
let storeInWorspace: boolean = this.hasWorkspaceFolders();
config.update(constants.trustedBooksConfigKey, bookPaths, storeInWorspace ? false : vscode.ConfigurationTarget.Global);
void config.update(constants.trustedBooksConfigKey, bookPaths, storeInWorspace ? false : vscode.ConfigurationTarget.Global);
}
hasWorkspaceFolders(): boolean {

View File

@@ -23,7 +23,7 @@ export class GitHubRemoteBook extends RemoteBook {
this.setLocalPath();
this.outputChannel.appendLine(loc.msgDownloadLocation(this.localPath.fsPath));
this.outputChannel.appendLine(loc.msgRemoteBookDownloadProgress);
this.createDirectory();
await this.createDirectory();
let notebookConfig = vscode.workspace.getConfiguration(constants.notebookConfigKey);
let downloadTimeout = notebookConfig[constants.remoteBookDownloadTimeout];