single-item: prevent circular refs

Signed-off-by: Varun Patil <radialapps@gmail.com>
pull/653/head
Varun Patil 2023-05-15 11:52:14 -07:00
parent bff4f44003
commit c5833c97ad
1 changed files with 7 additions and 5 deletions

View File

@ -13,16 +13,18 @@ export function isSingleItem(): boolean {
} }
export async function getSingleItemData(): Promise<IDay[]> { export async function getSingleItemData(): Promise<IDay[]> {
if (!singleItem?.fileid) { if (!singleItem?.fileid) return [];
return [];
}
// Make days array
singleItem.key = singleItem.fileid; singleItem.key = singleItem.fileid;
return [ const days = [
{ {
dayid: singleItem.dayid, dayid: singleItem.dayid,
count: 1, count: 1,
detail: [singleItem], detail: [singleItem],
}, },
] as any[]; ];
// Return copy to prevent circular reference
return JSON.parse(JSON.stringify(days));
} }