Show book's notebook TOC title in pinned notebooks view (#15583)

* Show notebook title in pinned notebooks view

* fix test

* change interface name
This commit is contained in:
Barbara Valdez
2021-05-27 14:09:51 -07:00
committed by GitHub
parent 2d71397ffe
commit aef6511ba6
5 changed files with 21 additions and 20 deletions

View File

@@ -435,7 +435,7 @@ export async function getRandomToken(size: number = 24): Promise<string> {
}
export function isBookItemPinned(notebookPath: string): boolean {
let pinnedNotebooks: IBookNotebook[] = getPinnedNotebooks();
let pinnedNotebooks: IPinnedNotebook[] = getPinnedNotebooks();
if (pinnedNotebooks?.find(x => x.notebookPath === notebookPath)) {
return true;
}
@@ -451,16 +451,16 @@ export function getNotebookType(book: BookTreeItemFormat): BookTreeItemType {
}
}
export function getPinnedNotebooks(): IBookNotebook[] {
export function getPinnedNotebooks(): IPinnedNotebook[] {
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(notebookConfigKey);
let pinnedNotebooks: [] = config.get(pinnedBooksConfigKey);
let updateFormat: boolean = false;
const pinnedBookDirectories = pinnedNotebooks.map(elem => {
if (typeof (elem) === 'string') {
updateFormat = true;
return { notebookPath: elem, bookPath: '' };
return { notebookPath: elem, bookPath: '', title: '' };
} else {
return elem as IBookNotebook;
return elem as IPinnedNotebook;
}
});
if (updateFormat) {
@@ -475,7 +475,7 @@ function hasWorkspaceFolders(): boolean {
return workspaceFolders && workspaceFolders.length > 0;
}
export async function setPinnedBookPathsInConfig(pinnedNotebookPaths: IBookNotebook[]): Promise<void> {
export async function setPinnedBookPathsInConfig(pinnedNotebookPaths: IPinnedNotebook[]): Promise<void> {
let config: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration(notebookConfigKey);
let storeInWorspace: boolean = hasWorkspaceFolders();
@@ -483,8 +483,9 @@ export async function setPinnedBookPathsInConfig(pinnedNotebookPaths: IBookNoteb
}
export interface IBookNotebook {
export interface IPinnedNotebook {
bookPath?: string;
title?: string;
notebookPath: string;
}