mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 13:48:12 +00:00
* if default section/page is missing then clear default notebook and hide option from dropdown. * handle edge case when section is null/undefined. * refactored notebook localstorage data + fixed some edge cases when default section/page gets deleted. Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
This commit is contained in:
@ -9,24 +9,24 @@ const TIME_BOUNDS = {
|
||||
};
|
||||
|
||||
export function addEntryIntoPage(notebookStorage, entries, entry) {
|
||||
const defaultSection = notebookStorage.section;
|
||||
const defaultPage = notebookStorage.page;
|
||||
if (!defaultSection || !defaultPage) {
|
||||
const defaultSectionId = notebookStorage.defaultSectionId;
|
||||
const defaultPageId = notebookStorage.defaultPageId;
|
||||
if (!defaultSectionId || !defaultPageId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newEntries = JSON.parse(JSON.stringify(entries));
|
||||
let section = newEntries[defaultSection.id];
|
||||
let section = newEntries[defaultSectionId];
|
||||
if (!section) {
|
||||
newEntries[defaultSection.id] = {};
|
||||
newEntries[defaultSectionId] = {};
|
||||
}
|
||||
|
||||
let page = newEntries[defaultSection.id][defaultPage.id];
|
||||
let page = newEntries[defaultSectionId][defaultPageId];
|
||||
if (!page) {
|
||||
newEntries[defaultSection.id][defaultPage.id] = [];
|
||||
newEntries[defaultSectionId][defaultPageId] = [];
|
||||
}
|
||||
|
||||
newEntries[defaultSection.id][defaultPage.id].push(entry);
|
||||
newEntries[defaultSectionId][defaultPageId].push(entry);
|
||||
|
||||
return newEntries;
|
||||
}
|
||||
|
Reference in New Issue
Block a user