mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
core: fix "Cannot read property type of undefined"
This commit is contained in:
@@ -143,7 +143,11 @@ export default class Notebooks extends Collection {
|
||||
* @returns {Notebook} The notebook of the given id
|
||||
*/
|
||||
notebook(id) {
|
||||
let notebook = id.type ? id : this._collection.getItem(id);
|
||||
if (!id) return;
|
||||
let notebook =
|
||||
typeof id === "object" && "type" in id
|
||||
? id
|
||||
: this._collection.getItem(id);
|
||||
if (!notebook || notebook.deleted) return;
|
||||
return new Notebook(notebook, this._db);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,10 @@ export default class Notes extends Collection {
|
||||
*/
|
||||
note(id) {
|
||||
if (!id) return;
|
||||
let note = id.type ? id : this._collection.getItem(id);
|
||||
let note =
|
||||
typeof id === "object" && "type" in id
|
||||
? id
|
||||
: this._collection.getItem(id);
|
||||
if (!note || note.deleted) return;
|
||||
return new Note(note, this._db);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user