Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function favoriteToIFile(fav: GetFavoritesQueryReturnValue): IFile {
const {notebook, notebookOwnerDetails} = fav;
notebook.ownerDetails = notebookOwnerDetails;
const {id, owner, dateCreated, dateUpdated, name} = notebook;
const ownerDetails = extractOwnerDetails(notebook);
return {
isLiked: true,
ownerDetails,
owner,
id,
dateCreated,
dateUpdated,
path: [],
name,
type: FileType.notebook,
};
}
} else {
const parentFile = convertToIFile(node.parentId, noteMap, resultMap);
path = parentFile.path.concat([{id: parentFile.id, name: parentFile.name}]);
}
const name =
node.type === FileType.folder ? node.folder!.name : node.notebook!.name;
const result: IFile = {
id: node.type === FileType.folder ? id : node.notebookId!,
dateCreated,
dateUpdated,
type,
name,
owner,
ownerDetails: extractOwnerDetails(node),
isLiked: false,
path,
};
resultMap.set(id, result);
return result;
}
export function convertSingleNodeToIFile(
node: DbFileTreeNode,
path: IFilePathItem[],
) {
const {id, dateCreated, dateUpdated, owner, type} = node;
const name = computeName(node);
const nodeAsFile: IFile = {
id,
name,
path,
dateCreated,
dateUpdated,
owner,
ownerDetails: extractOwnerDetails(node),
type,
isLiked: false,
};
return nodeAsFile;
}