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

@@ -6,7 +6,7 @@ import * as path from 'path';
import * as vscode from 'vscode';
import * as constants from './../common/constants';
import { BookTreeItem } from './bookTreeItem';
import { getPinnedNotebooks, setPinnedBookPathsInConfig, IBookNotebook } from '../common/utils';
import { getPinnedNotebooks, setPinnedBookPathsInConfig, IPinnedNotebook } from '../common/utils';
export interface IBookPinManager {
pinNotebook(notebook: BookTreeItem): Promise<boolean>;
@@ -51,14 +51,14 @@ export class BookPinManager implements IBookPinManager {
let modifiedPinnedBooks = false;
let bookPathToChange: string = notebook.book.contentPath;
let pinnedBooks: IBookNotebook[] = getPinnedNotebooks();
let pinnedBooks: IPinnedNotebook[] = getPinnedNotebooks();
let existingBookIndex = pinnedBooks.map(pinnedBookPath => path.normalize(pinnedBookPath?.notebookPath)).indexOf(path.normalize(bookPathToChange));
if (existingBookIndex !== -1 && operation === PinBookOperation.Unpin) {
pinnedBooks.splice(existingBookIndex, 1);
modifiedPinnedBooks = true;
} else if (existingBookIndex === -1 && operation === PinBookOperation.Pin) {
let addNotebook: IBookNotebook = { notebookPath: bookPathToChange, bookPath: notebook.book.root };
let addNotebook: IPinnedNotebook = { notebookPath: bookPathToChange, bookPath: notebook.book.root, title: notebook.book.title };
pinnedBooks.push(addNotebook);
modifiedPinnedBooks = true;
}