mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
* add await to refresh book method * change name of method * Reload tree view * address pr comments * adding finally on finally
This commit is contained in:
@@ -93,7 +93,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
setFileWatcher(book: BookModel): void {
|
setFileWatcher(book: BookModel): void {
|
||||||
fs.watchFile(book.tableOfContentsPath, async (curr, prev) => {
|
fs.watchFile(book.tableOfContentsPath, async (curr, prev) => {
|
||||||
if (curr.mtime > prev.mtime) {
|
if (curr.mtime > prev.mtime) {
|
||||||
this.fireBookRefresh(book);
|
await this.initializeBookContents(book);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -223,11 +223,14 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
await this.bookTocManager.recovery();
|
await this.bookTocManager.recovery();
|
||||||
vscode.window.showErrorMessage(loc.editBookError(updateBook.book.contentPath, e instanceof Error ? e.message : e));
|
vscode.window.showErrorMessage(loc.editBookError(updateBook.book.contentPath, e instanceof Error ? e.message : e));
|
||||||
} finally {
|
} finally {
|
||||||
this.fireBookRefresh(targetBook);
|
try {
|
||||||
if (sourceBook) {
|
await targetBook.initializeContents();
|
||||||
|
if (sourceBook && sourceBook.bookPath !== targetBook.bookPath) {
|
||||||
// refresh source book model to pick up latest changes
|
// refresh source book model to pick up latest changes
|
||||||
this.fireBookRefresh(sourceBook);
|
await sourceBook.initializeContents();
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this._onDidChangeTreeData.fire(undefined);
|
||||||
// even if it fails, we still need to watch the toc file again.
|
// even if it fails, we still need to watch the toc file again.
|
||||||
if (sourceBook) {
|
if (sourceBook) {
|
||||||
this.setFileWatcher(sourceBook);
|
this.setFileWatcher(sourceBook);
|
||||||
@@ -235,6 +238,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async openBook(bookPath: string, urlToOpen?: string, showPreview?: boolean, isNotebook?: boolean): Promise<void> {
|
async openBook(bookPath: string, urlToOpen?: string, showPreview?: boolean, isNotebook?: boolean): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@@ -262,7 +266,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
if (curr.mtime > prev.mtime) {
|
if (curr.mtime > prev.mtime) {
|
||||||
let book = this.books.find(book => book.bookPath === bookPath);
|
let book = this.books.find(book => book.bookPath === bookPath);
|
||||||
if (book) {
|
if (book) {
|
||||||
this.fireBookRefresh(book);
|
await this.initializeBookContents(book);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -293,7 +297,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
}
|
}
|
||||||
|
|
||||||
@debounce(1500)
|
@debounce(1500)
|
||||||
async fireBookRefresh(book: BookModel): Promise<void> {
|
async initializeBookContents(book: BookModel): Promise<void> {
|
||||||
await book.initializeContents().then(() => {
|
await book.initializeContents().then(() => {
|
||||||
this._onDidChangeTreeData.fire(undefined);
|
this._onDidChangeTreeData.fire(undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user